# 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? =)

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!
-Nick

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.

Lemme know if that works for you!
-Nick

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

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

#just for reference
smiley2.reparentTo(render)

smiley.reparentTo(anp)

base.physicsMgr.attachPhysicalNode(an)

base.enableParticles()

localVel = Vec3(0,1,0)

globalVel = render.getRelativeVector( anp, localVel )

anp.setH(90)

sak = an.getPhysicsObject()
sak.setVelocity(globalVel)

run()

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 )``````

and:

``````
anp.setH(90)``````

?

David

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 ! =)