I’m trying to build a 3 lane runner with similar mechanics to Subway Surfer.
Using c# what is the technique I could use to move the player smoothly from one lane to the next?
I have a RigidBody attached to my player so I am of the understanding that I need to use AddForce().
Currently I am doing something like this.
void Update() {
if (Input.GetKey("left"))
rigidbody.AddForce(15, 0, 0);
if (Input.GetKey("right"))
rigidbody.AddForce(-15, 0, 0);
}
In psuedo code I’m trying to do :
IF key pressed, THEN move player 5 units along the X axis.
Any suggestions?
Thanks