- Joined
- Oct 2, 2024
- Messages
- 1,387
- Level up in
- 1113 posts
- Reaction score
- 5,763
- Points
- 3,477
If you want to handle 3D movement, grab your forward vector and multiply that by a new vector3 that consists of your horizontal and vertical input, do not apply anything to the Y.
var direction = object.transform.forward * vector3(h, 0, v);
A cool trick if you handle analogue movement is to grab the lenght of the input if it's a vector
let magnitude = input.lenght()
then add that when calculating the velocity
velocity = direction * speed * magnitude
this will let you smoothly handle analogue input, if the player moves the stick slowly the object will move accordingly instead of reaching it's maximum velocity.
you could mimic this with lerp if you are using keyboard input but might require additional input.
var direction = object.transform.forward * vector3(h, 0, v);
A cool trick if you handle analogue movement is to grab the lenght of the input if it's a vector
let magnitude = input.lenght()
then add that when calculating the velocity
velocity = direction * speed * magnitude
this will let you smoothly handle analogue input, if the player moves the stick slowly the object will move accordingly instead of reaching it's maximum velocity.
you could mimic this with lerp if you are using keyboard input but might require additional input.