Question by
Vastatio · Jun 21, 2016 at 04:51 AM ·
animationrigidbodythird person controller
how do you make a 3rd person controller with no turning animation?
Hey, so I want to make a third person character using Mechanim. I don't want the character to turn, just run instantly rotate to the direction where the arrow key is pressed: - If they press W, they run forward - If they press D, they run to the left (no turning, then W) and so on........
How would I go about doing this? Do i make quaternions to rotate the model? and how would I even implement this? my current code to make the player just move forward is this:
public class Movement : MonoBehaviour {
public Animator animator;
public Rigidbody rb;
public float moveSpeed = 0.5f;
void Start () {
animator = GetComponent<Animator>();
rb = GetComponent<Rigidbody>();
}
void FixedUpdate () {
Move();
}
void Move() {
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
animator.SetFloat("Forward", moveVertical);
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
if (moveVertical > 0.1f) { rb.AddForce(movement * moveSpeed); }
if (moveVertical < 0) { rb.AddForce(movement * -moveSpeed); }
}
}
Thanks.
Comment
Your answer