I want a very simple character controller, a character that moves around in all directions and faces the direction he’s moving in. But I’m confused about how to achieve that, I find vector3 stuff confusing in general. How would I make this code use force and clamp the speed of the character’s movement and have him keep on facing the direction he’s moving in. Right now after he stops moving the rotation is reset.
public float speed;
bool canPlayerMove = true;
void Start()
{
}
void FixedUpdate()
{
float moveHorizontal = -Input.GetAxisRaw("LeftJoyStickHorizontal");
float moveVertical = Input.GetAxisRaw("LeftJoyStickVertical");
if (canPlayerMove)
{
Vector3 movement = new Vector3(moveVertical, 0.0f, moveHorizontal);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(movement), 0.15F);
transform.Translate(movement * speed * Time.deltaTime, Space.World);
}
}