Moving player side-to-side with mouse

I’m making a first-person endless runner where you can move the player with the mouse from side-to-side like in Audiosurf. I’m not sure how to do that with 3D objects. I’ve looked at the different Vector3 functions with the Camera class (e.g. ScreenToWorldPoint()), but I’m still confused as to how they work in conjunction with each other.

Could anyone help me out with moving the player side-to-side with the mouse?

Input.GetAxis

Transform.Translate

 float horizontalMovement = Input.GetAxis("Horizontal");
 object.translate(0, horizontalMovement, 0);

Odds are, you probably want to take the cursor position (Input.mousePosition) each frame, apply it to the position of your player, and then reset the mouse to the center of the screen. This is what most FPS games do, allowing ‘endless’ mouse movement.

Basically, each frame you take how far the mouse is away from the center of the screen (Screen.width/2, Screen.height/2), and then set the mouse back to the center.

Hope this helps :slight_smile: