Unity Character Controller Movement

PHOTO EMBED

Tue Jan 26 2021 13:39:39 GMT+0000 (UTC)

Saved by @cotterdev #c#

//Get inputs
float horzInput = Input.GetAxis("Horizontal");
float vertInput = Input.GetAxis("Vertical");

//Calc Velocity
Vector3 direction = new Vector3(horzInput, 0.0f, vertInput);
Vector3 velocity = direction * _speed;

//Gravity
velocity.y -= _gravity;

//Convert localSpace velocity to worldSpace
//velocity = transform.transform.TransformDirection(velocity);
velocity = transform.TransformDirection(velocity);

//Move
_controller.Move(velocity * Time.deltaTime);
content_copyCOPY