Created
December 28, 2024 08:24
-
-
Save todorok1/f9ee50bcb436f63e4797fe7ff352a9d3 to your computer and use it in GitHub Desktop.
シンプルRPGのチュートリアル アニメーションの遷移の確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class AnimTest : MonoBehaviour | |
{ | |
Animator animator; | |
// Start is called once before the first execution of Update after the MonoBehaviour is created | |
void Start() | |
{ | |
animator = gameObject.GetComponent<Animator>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.DownArrow)) | |
{ | |
animator.SetInteger("Direction", 0); | |
} | |
if (Input.GetKeyDown(KeyCode.RightArrow)) | |
{ | |
animator.SetInteger("Direction", 1); | |
} | |
if (Input.GetKeyDown(KeyCode.UpArrow)) | |
{ | |
animator.SetInteger("Direction", 2); | |
} | |
if (Input.GetKeyDown(KeyCode.LeftArrow)) | |
{ | |
animator.SetInteger("Direction", 3); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment