Hi, I’ve been looking for some time now but I cant seem to figure out how to roll a ball in only 4 directions (Up,Down,Left,Right). Does anyone know or have a code on how I can achieve this. I want to lock all diagonal movement as close as I can. Maybe to stop all motion before I apply my next key stroke? Please help!
You should be able to achieve this effect by setting the rigidbody’s velocity directly.
// Change xSpeed and ySpeed to be whatever you want on whichever axises your game uses
rigidbody.velocity = new Vector3(xSpeed, ySpeed, 0f);
You would just have to make sure that when you are setting your xSpeed and ySpeed based on the player’s directional input that they cannot have a value for both xSpeed or ySpeed (in other words, at least one of them would have to be zero).