So I want to make my animation transitions smooth, thats why I made transitions on the animator, but how can I activate them if I use trigger paramaters??? Heres the code:
public float speed = 0.3f;
public float sprintSpeed = 2.5f;
private Rigidbody rigidB;
private float midJump = 1f;
public float rotSpeed = 2;
Animator anim;
void Start()
{
rigidB = GetComponent<Rigidbody>();
anim = GetComponent<Animator>();
}
void Update()
{
//Character rotation with A and D
var z = Input.GetAxis("Horizontal") * rotSpeed;
//Character movement with W and S
var y = Input.GetAxis("Vertical") * speed;
//Character animations
if (Input.GetKey(KeyCode.RightShift))
y = y * sprintSpeed;
if (Input.GetKey(KeyCode.RightShift) && y > 0.31)
anim.Play("Sprint");
if (y < 0.001)
anim.Play("Idle");
if (y > 0.001 && y < 0.31)
anim.Play("Run");
transform.Translate(0, -y, 0);
transform.Rotate(0, 0, -z);
//Character Jump
if (midJump == 1 && Input.GetKeyDown(KeyCode.Space))
{
rigidB.velocity = new Vector3(0, 45, 0);
midJump = 2;
}
else if (rigidB.velocity.y == 0)
midJump = 1;
}