- Home /
How can I create a sphere rotate in based on the direction it's moving?
I was wondering how can I make the player a simple sphere, then when you press the WASD keys and your player move, the ball rotates. Like you control the ball.
Sorry I'm not very specific...Basically, How do I use the WASD keys to make a ball rotate based on the angle the camera is on it...
"Sorry I'm not very specific". Yes. But don't be sorry, be more specific.
You write that the keys move the ball, then you write they rotate the ball. Do you want to keys to rotate the ball, which should then make it move? Then you add camera angle at the very end. Is that part important?
Are you having trouble moving relative to the camera view? Or is it moving fine, but the rotation needs to look more like a proper rolling ball?
Are you having trouble just reading from the WASD keys? There are lots of examples of doing that, and moving.
Answer by Jakeiiii · Jan 31, 2015 at 06:00 PM
Do you mean if you press forward/up, you move forward/up depending on which way the camera's facing? If so, then have your script find the camera object and have the velocity equal to: the camera's forward times Input.GetAxis("Vertical") plus the camera's right times Input.GetAxis("Horizontal"). If the camera is titled down to look at the ball, make vectors that are equal to the camera's forward and right, and make the y value 0. Then it should move up/forward depending on whichever way the camera is looking at the ball.
I was thinking something like the movement in the game "Super $$anonymous$$onkey Ball" where you can rotate a ball around a track with the camera following. Would that work the same way?