- Home /
AddForce to object
Hi everyone, sorry for so many questions tonight but every time I fix one thing, I move onto another problem.
I've set up a object which I want to fly around the scene. The user controls this object (A bird). The bird works exactly like a plane, in the sense that it has thrust, drag and what not. I originally decided to have a separate game object for the AddForce, however this just isn't practical. So here's what I want to do :
Make the bird increase speed over time, with a maximum speed. Add the force from the bird object itself, not a separate object.
Now I tried simply adding force behind the object, but for some reason, the 'Forward' direction of the object was not the forward I was expecting (As it went diagonally).
How would I achieve this? How can I add force to the object and make sure that it goes forwards?
Note - I need to keep gravity on
~ Alex
How about to add some of your code? What "`forward`" do you use? How do You apply the force? AddForce? AddRelativeForce? AddForceAtPosition? In general AddForce works in world space and transform.forward returns the forward direction in worldspace. AddRelativeForce works in local space and to apply a forward speed you would use Vector3.forward.
Answer by efge · Mar 14, 2011 at 08:13 PM
You should use AddRelativeForce (and AddRelativeTorque) to add forces relative to the coordinate system of your bird object.
Answer by Noah-1 · Mar 14, 2011 at 08:07 PM
Hello.
Well you need to see first if your vectors are aligned properly. (Check globals and locals).
Answer by CHPedersen · May 26, 2011 at 07:02 AM
[Edited to empty - answered wrong question by some mistake]
... What the..?! That's totally not the question I meant to answer. I swear I clicked on a different question before I typed that out. O_O ... Err... I'm gonna edit that and leave an empty answer. Sorry folks.