Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created April 30, 2015 17:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/9a1e1c025d30202e12d6 to your computer and use it in GitHub Desktop.
Save tsubaki/9a1e1c025d30202e12d6 to your computer and use it in GitHub Desktop.
StateMachineBehaviourの挙動
using UnityEngine;
public class BooleanSwitchByKey : StateMachineBehaviour
{
[SerializeField]
KeyCode keycode;
[SerializeField]
string parameterName;
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.SetBool(parameterName, Input.GetKey(keycode));
}
}
using UnityEngine;
using System.Collections;
public class Walk : StateMachineBehaviour {
[SerializeField, Range(0, 3)]
float speed = 0;
override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Transform transform = animator.transform;
transform.position += transform.right * speed * Time.deltaTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment