I am making a jumping and idle animations in UNITY 3d. Here is the code:
using UnityEngine; using System.Collections;
public class JumpingD : MonoBehaviour {
public Animator anim;
public float JumpSpeed_;
private RigidBody _Character; //rigid body of the Character
public Vector3 JumpVector;
/*The thresh Hold level for the character to jump are
1: Stay Idle
25: Jump Up
*/
void Start ()
{
anim=GetComponent<Animator>();
anim.SetFloat("JumpSpeed", 1)
}
void Update ()
{
anim.SetFloat("JumpSpeed", 1)
if(Input.GetKeyDown(KeyCode.J))
{
_Character.AddForce(JumpVector*Time.deltaTime);
anim.SetFloat("JumpSpeed", 25)
}
}
}
The problem is the jump animation don't play even after pressed J key. Always the idle animation plays I want the jump animation to play after I pressed J key and after that the character goes idle again.