# Having problems with getPos on a bullet vehicle

I am a nooby and hope I am not making a fool of myself with my question. I am busy going through the tutorial trying to learn how to design and code 3D games. Each time I read something cool, I will test it either on new code or modify one of your samples. My 5 yr old was getting impatient with me, so I tried to create something quick and dirty. He likes CARS. So I take the bullet vehicle sample and add a surface from the shadow sample. Then I add game pad control. Then I tried to add following camera logic from the Roaming Ralph. But the camera did not move when the car moved. I then added print statements to see where the problem is. The getPos on the yugoNP node always returns (0,0,0). I spent several days going through the manuals and forums to find a solution. Nothing. Any help is greatly appreciated.

What is â€śyugoNPâ€ť? Could you show us some code, perhaps?

More generally, Iâ€™d guess that â€śyugoNPâ€ť is attached to some other NodePath, and that its position relative to that NodePath is left unchanged. You see, when â€śgetPosâ€ť is called with no further arguments, it returns the position of the NodePath relative to its parent. Thus if â€śyugoNPâ€ť is attached to something, set to be at (0, 0, 0), and that something is then moved around, â€śyugoNP.getPos()â€ť will nevertheless continue to return (0, 0, 0), I believe.

If you want to get a position relative to another NodePathâ€“e.g. the standard scene-root, â€śrenderâ€ťâ€“you can pass in that NodePath as a parameter to â€śgetPosâ€ť.

Thus, to get the position of â€śyugoNPâ€ť relative to another NodePath, you might call the following:

``````pos = yugoNP.getPos(someOtherNodePath)
``````

And to get the position of â€śyugoNPâ€ť relative to â€śrenderâ€ť, specifically, you might call the following:

``````pos = yugoNP.getPos(render)
``````

Problem is solved with your suggestion.

This is part of the code sample collection that comes with Panda3D.

``````np = self.worldNP.attachNewNode(BulletRigidBodyNode('Vehicle'))
np.setPos(80, 50, 1)
np.node().setMass(800.0)
np.node().setDeactivationEnabled(False)

self.world.attachRigidBody(np.node())

# Vehicle
self.vehicle = BulletVehicle(self.world, np.node())
self.vehicle.setCoordinateSystem(ZUp)
self.world.attachVehicle(self.vehicle)

self.yugoNP.reparentTo(np)
``````

## Do these items during every Loop

dt = globalClock.getDt()

``````self.processInput(dt)
self.world.doPhysics(dt, 10, 0.008)

## Setup camera tracking ################
self.camera.setPos(self.yugoNP.getX(render), self.yugoNP.getY(render) - 20, self.yugoNP.getZ(render) + 16)

self.camera.lookAt(self.yugoNP)

``````

Your suggestion DID work. I added â€śrenderâ€ť to the getPos() to make it getPos(render).
Problem solved. Thanks.

I know I have a long way to go before I have a decent understanding. But hands-on is much better than just reading.

Iâ€™m glad that you got it working.

If I may, I have a â€śbeginnerâ€™s tutorialâ€ť that may be of interest to you: it takes one through the basics of using the engine, from some of the fundamental concepts, through implementation, and on to building a distributable.

If youâ€™re interested, you should find it here:

Thanks. I am currently in China. That server is blocked. I will bookmark it anyway.

Unless you have an alternative method of getting it to me. Haha

Ah, thatâ€™s a pity! Good old China and its censorship. `:/`

Humâ€¦ The assets and image-files for the tutorial are likewise stored on GitHub, so if the main page is restricted, then Iâ€™m guessing that the assets are, too. Short of dumping everything into DropBox (and is that restrictedâ€¦?), Iâ€™m not sure of what to do.

GitHub works fine.

Censorship is a royal pain. I am missing out on lots of great content. Canâ€™t wait until it is safe to travel again. Probably not going to happen this year.

Well, if you can access GitHub, then you might be able to access the base repository that hosts the tutorial. (Note that the link that I gave was a Github linkâ€“but one specific to GitHubâ€™s document-hosting interface.)

Iâ€™m not sure of whether base GitHub will parse the markup for you, or whether youâ€™ll have to either deal with the markup or find a viewer for it.

Here, then, is the base GitHub link: