Setting velocity localy?

I know that forces can be applyed localy to objects using forceNodes… But can i apply velocity using an obejcts local coordinate system? Ofcorse you can but the question is how? =)

Hello Slinker!

I believe that the coordinate system of the force node determines what coordinate system the force is applied. So if you want it to be in the local coordinate system, simply attach the force node to the local object. = )

Hope that helps!

The question was realy how to set velocity in a local coordinate system. Not how to set forces localy.

DOH! Read too fast. Sorry bout that. Never done that, but doing some quick digging through the API, I’d say you can convert the local velocity into a global velocity using getRelativeVector, like:

localVel = Vec3( 1, 0, 0 )
globalVel = render.getRelativeVector( targetNP, localVel )
targetNP.node().getPhysicsObject().setVelocity( globalVel )

No clue it the above is valid syntax, but hopefully should give an idea of what I mean. :slight_smile:

Lemme know if that works for you!

nothing realy happens. No errors no nothing =) Her is my code:

an = ActorNode(‘smiley’)
anp = render.attachNewNode(an)

#just for reference
smiley2 = loader.loadModel(“models/smiley”)

smiley = loader.loadModel(“models/smiley”)




localVel = Vec3(0,1,0)

globalVel = render.getRelativeVector( anp, localVel )


sak = an.getPhysicsObject()


When I paste in your code, I get two smileys slowly drifting apart.

Did you mean to reverse the order of:

globalVel = render.getRelativeVector( anp, localVel )





Im trying to make one of the smileys move in the direction its facing using velocity ?

Dho =) It works fine now, thank u both! This realy helps me! Thanks agein ! =)