I am currently working on a top down game and I am almost done with the character movement but I ran into a problem: transform.Translate doesn’t stop immediately when I release the movement buttons. Instead, it slowly stops. I don’t want this as I am going to add animations to my character and I don’t want it to look weird when you want to stop moving.
Here is the code I am currently using:
using UnityEngine;
using System.Collections;
public class CharacterController : MonoBehaviour {
Rigidbody Ridgidbody;
public float Speed = 1;
// Use this for initialization
void Start () {
Ridgidbody = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
float Horizontal = Input.GetAxis("Horizontal");
float Vertical = Input.GetAxis("Vertical");
Vector3 Movement = new Vector3(Horizontal, 0, Vertical);
transform.Translate(Movement * Time.deltaTime * Speed);
}
}
I hope anyone knows an answer to my problem.
Greetings