- Home /
 
How can I make player move with cursor?,How can I make player move with mouse?
I´m trying to make rolling sky/hop replica. I want, that if I move my cursor left in game the player moves with mouse to the left. How can I do that in unity?? Any help is appreciated.
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by victorbisaev · Feb 01, 2018 at 10:54 PM
To get the current mouse position you can use Input.GetAxis("Mouse X") and Input.GetAxis("Mouse Y") to get mouse deltaX and deltaY relative to a previous frame correspondingly.
Then you can apply the mouse delta movement values to the position of your player like this:
 void Update()
 {
     float h = Input.GetAxis("Mouse X");
     float v = Input.GetAxis("Mouse Y");
     playerGameObject.transform.Translate(h, 0, v);
 }
 
              Your answer