moveDirection = new Vector3(Input.GetAxis(“Horizontal”), 0, Input.GetAxis(“Vertical”));
moveDirection = speed;
rigidbody.AddForce(moveDirection * Time.deltaTime100 );
When the velocity of the sphere is in east or the sphere is moving in east, I want the UP button to move the sphere in the east(as in any car game). But on pressing UP the sphere starts moving in the NORTH … I understand why but I couldn’t get any solution to this problem. Please help as this is my first game and it’s really frustrating to not be able to solve such simple problem.
First of all, start thinking about the transform of the object you are moving. Since you are making a car game, you will probably want it to turn and face the direction of travel, start by making sure that is true. You should then think about the properties of the transform like ‘forward’ and ‘right’ - you can scale these to give you some forces that you ought to find useful.
yes , you are right … and I solved the problem.
If it was not sphere I could have simply rotated the object along the y-axis and applied the force along transform.forward vector.
But since it is sphere I can not do that so I just freezed the rotation along any axis and finally done the same thing to move the sphere (that is rotation + force along transform.forward).
Thanks to both of you for your valuable time …