I would like to make my character move when I press a button. Though, I would only like to move a specific distance, like 50 pixels for example, so I tried this out:
You will need to know which “pixel” the character is on…
Camera.WorldToScreenPoint will get you which pixel you are on, Then do a addition of Game.numberToMove in the direction you want to go. Your best bet then is to create a plane where the player is, then do a Camera.ScreenPointToRay on the new coordinates and position the player on the intersection to the plane.
Hi, thanks for replying. I suppose this requires my main camera to be located at the same place as the player. The camera is setup like 3rd person view, will this still work?
Actually, when you build your “plane” you build it in the Camera.forward direction, not the player direction. This will always move it X pixels according to the camera.