[Lots of Pictures] Idle to Run Animation Delay? When Pressing Forward Slides forward without Animation
Hi I'm very new to 3D animation/game programming! My questions is for transitioning from my idle animation to my run animation. If I press the "UP" key or "W" key the character slides forward without the animation playing. I believe it takes about a half second - one second for the animation to kick in.
How can I remove the or reduce the delay between switching these animations?
I hope this question makes sense I will attach some images and a GIF. Please let me know if I need to provide anymore information or if there is something I should have read before bringing up this question!
Animation Controller: Script:
using UnityEngine; using System.Collections;
public class newScript : MonoBehaviour {
private Animator anim;
private CharacterController controller;
public float speed = 6.0f;
public float turnSpeed = 60.0f;
private Vector3 moveDirection = Vector3.zero;
public float gravity = 20.0f;
// Use this for initialization
void Start () {
anim = gameObject.GetComponentInChildren<Animator>();
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update () {
if (Input.GetAxis("Vertical") == 1)
{
anim.SetInteger("animParm", 1);
}
else
{
anim.SetInteger("animParm", 0);
}
if (controller.isGrounded)
{
moveDirection = transform.forward * Input.GetAxis("Vertical") * speed;
if(Input.GetKey("space"))
{
moveDirection.y += gravity*25;
}
}
float turn = Input.GetAxis("Horizontal");
transform.Rotate(0, turn * turnSpeed, 0);
controller.Move(moveDirection);
moveDirection.y -= gravity;
}
}
Your answer
Follow this Question
Related Questions
Animation start delay 0 Answers
2D Animation Delay 3 Answers
Delay in animation?,Delay in Animations How to solve? 0 Answers
Delay Animator Action in C#? 0 Answers