|
Java Code - Animator
[Back]
Code:
//You put these on the top of the script, these are the start of it.
var Speed : float = 10; //The Player Speed
var anim : Animator; //Hold a Animator
//Put this next code in function Start ()
//This will get the Component for the Animator
function Start () {
anim = GetComponent(Animator);
}
//These codes make it so when you hit the button it will set the animator Parameters for Speed to the var Speed of //player code, make sure you make a Float parameter for the animator.
if (Input.GetButton ("a"))
{
anim.SetFloat("Speed", Speed);
//The first Speed is for the animator the next speed is the player var speed
}
if (Input.GetButton ("d"))
{
anim.SetFloat("Speed", Speed);
}
if (Input.GetKeyUp ("a")){
anim.SetFloat("Speed", 0);
//This will make it so when the key is up it will set the animator speed to 0
}
if (Input.GetKeyUp ("d")){
anim.SetFloat("Speed", 0);
}
//Edit Other
anim.SetFloat("TEST", 0); //Edit Float
anim.SetInteger("TEST", 1); //Edit Int
anim.SetBool("TEST",true); //Edit true and false
//Check If
//Win is the name of the Parameters for the Animator
if (anim.GetBool("Win") == false) {
}
if (anim.GetInteger("Win") == 0) {
}
if (anim.GetFloat("Win") >= 0) {
}
var Speed : float = 10; //The Player Speed
var anim : Animator; //Hold a Animator
//Put this next code in function Start ()
//This will get the Component for the Animator
function Start () {
anim = GetComponent(Animator);
}
//These codes make it so when you hit the button it will set the animator Parameters for Speed to the var Speed of //player code, make sure you make a Float parameter for the animator.
if (Input.GetButton ("a"))
{
anim.SetFloat("Speed", Speed);
//The first Speed is for the animator the next speed is the player var speed
}
if (Input.GetButton ("d"))
{
anim.SetFloat("Speed", Speed);
}
if (Input.GetKeyUp ("a")){
anim.SetFloat("Speed", 0);
//This will make it so when the key is up it will set the animator speed to 0
}
if (Input.GetKeyUp ("d")){
anim.SetFloat("Speed", 0);
}
//Edit Other
anim.SetFloat("TEST", 0); //Edit Float
anim.SetInteger("TEST", 1); //Edit Int
anim.SetBool("TEST",true); //Edit true and false
//Check If
//Win is the name of the Parameters for the Animator
if (anim.GetBool("Win") == false) {
}
if (anim.GetInteger("Win") == 0) {
}
if (anim.GetFloat("Win") >= 0) {
}