|
I am using input from the player
to move a sphere rigidbody using
I would like to use the input
To turn the sphere. In other words, I would like to adjust the the Quaternion of the shpere so that the forward momentum generated by rigidbody.AddForce changes direction one degree + or - as the player is pressing left, right arrows All of my attempts result in the shpere turning, but not changing the forward momentum direction. Any ideas how to do this?
(comments are locked)
|
|
EDIT: Saw you wanted to use AddForce, Im not sure, but I guess this same principel should work with that also. BTW: This is done in C# Tried to make a quick example, I think this should do the trick, Fiddle about with it, to get it to fit what your trying to do.
using System.Collections; public class testMovementScript : MonoBehaviour {
} Yes, this is exactly want I meant. I had suspected that it was by somehow using the translation conponent of the object. Very helpful!
Aug 11 '10 at 03:51 PM
TinyUtopia
(comments are locked)
|
|
I'm not sure if I understood what you want to do. If you want a force that points into another direction all you have to do is rotate the force before you add it. If you want to change the direction of the momentum the sphere already has you will have to rotate the spheres rigidbody.velocity accordingly.
(comments are locked)
|
|
You need to track the forward direction yourself as a variable and apply a constant force in that direction to maintain movement in the correct direction. Use a highish drag value to prevent the ball from picking up speed over time. When you press the left and right keys rotate the forward direction and apply a force relative to the forward direction. Placing the sphere in a container game object will help you with keeping the correct forward direction. It's a bit of a round about way but movement like you describe isn't very realistic.
(comments are locked)
|
