- Home /
rolling ball movement on different axis
hey. Am making a ball rolling game where you go down a hill destroying things and have the ball moving but not how i want. the JS is
var xForce : float = 10; var yForce : float = 10; var zForce : float = 10;
function Update () {
if (Input.GetKey ("up")) rigidbody.AddForce(Vector3(0, 0, 10));
if (Input.GetKey ("right"))
rigidbody.AddForce(Vector3(10, 0, 0));
if (Input.GetKey ("down"))
rigidbody.AddForce(-Vector3(0, 0, 10));
if (Input.GetKey ("left"))
rigidbody.AddForce(-Vector3(10, 0, 0));
}
as you can see the ball moves up, left, down and right but because the level/terrain is a spiral shape, as you are going down the directional buttons will change the way the ball is moving because the directions are related to the terrain and not the ball. makes sense? so can someone please help me make the ball travel forward when up is pressed etc all the way down a spiral level please?
Your answer
Follow this Question
Related Questions
Rigidbody AddForce not colliding to objects with Colliders 0 Answers
Ball Addforce Acceleration Speed 1 Answer
Ball rolling on platform 0 Answers
Ball Rotating Help 0 Answers
Why is my Rigidbody Ball not rolling on contact with Terrain? 1 Answer