# confused about torque in bullet in panda3d

Hi. I’m slowly learning more and more panda3d. and loving it

one thing I am confused about is how to make force push an object in the relative direction.

For example, I have a shuttle in space. If I rotate the ship and then apply force the ship does not move in the direction its facing but rather on the x axis.

It’s a gap in knowledge but one I do not know how to fix, have searched the forums but no able to find the answer.

on a related note, if this is kind of question thats. been asked a thousand times, it’d be worthy of a sticky faq thread perhaps. where popular questions and answers could be easily found.

Cheers!

Ps, what version bullet is included in panda3d. 1.80

Here’s what I do:

``````force = Vec3(0, 1, 0) # Forward
vector = ship.getParent().getRelativeVector(ship, force)
ship.applyCentralForce(vector)``````

thanks for the answer rbd! I’ll try it out.

is the ship object you are referring to a mesh or node or a nested bullet node NODENAME1.node()?

EDIT - i’m trying this in my input event ahndeler section’

``````        vector = self.rocket1.node().getParent().getRelativeVector(self.rocket1.node(), force)

self.rocket1.node().setActive(True)
#self.rocket1.node().applyCentralForce(force)
self.rocket1.node().applyCentralForce(vector)
self.rocket1.node().applyTorque(torque)``````

but have error AttributeError: ‘libpandabullet.BulletRigidBodyNode’ object has no attribute ‘getRelativeVector’

agian my lack of knowledge

edit 2 solved it.

``````    def processInput(self,dt):
moveto=[]
force = Vec3(0, 0, 0) # Forward
torque = Vec3(0,0,0)

if inputState.isSet('forward'):
force.setY(-10.0)

if inputState.isSet('back'):
force.setY(10.0)

if inputState.isSet('right'):
torque.setZ(-3.0)

if inputState.isSet('left'):
torque.setZ(3.0)

if inputState.isSet('up'):
torque.setX(-3.0)

if inputState.isSet('down'):
torque.setX(3.0)

if inputState.isSet('shoot'):
print ("camera pos is", self.camX, self.camY , self.camZ)

if inputState.isSet('movehere'):
moveto = self.getMouseXY()
print ("mouse is at",moveto)
spaceS = self.make_space_station(moveto[0],moveto[1],0)
#spaceS.setPos(moveto[0],moveto[1],0)

self.rocket1.node().setActive(True)
force = render.getRelativeVector(self.rocket1, force)

self.rocket1.node().applyCentralForce(force)
self.rocket1.node().applyTorque(torque)``````

based on your exampe, which i used in google and found this awesome post by ennox. helped a ton.

panda3d.org/forums/viewtopic … fc241d7aaa

getRelativeVector should be referring to the NodePath, in your case self.rocket1. The force is applied to the BulletRigidBodyNode, in your case self.rocket1.node().