How to get position when pushed

Hello, I come to disturb you again about CollisionPusher
:smiley:

This my situation

  1. I create the car beside the building
  2. I move(drive) the car toward that building
  3. when crashing, the building push back the car automatically
    because my car is added to CollisionPusher

The question is, how can I get the position after the car is pushed back?
Note that, I position the car through the nodePath function using:

car.setPos(x, y, z)

and if I cannot check when the car hit the building, so the object will still stay move forward and cause the errors.

Thank you for any answers of my old questions and this question.

I believe you’re looking for

car.getPos()

This will return a Point3D or a Vec3, I can’t remember which.

pos = car.getPos()

I usually manipulate position of vehicles by simply advancing in the Y direction of the model’s space. So you wouldn’t actually need to know the current position in global space.

I typically have movement in a task and measusre “dt” as time between frames. Remember from physics that distance = velocity X time. Thus:

car.setPos(car,Vec3(0,1*dt*self.speed,0))

This code advances the car in its y-axis direction at a constant speed regardless of framerate.

Two remarks:

It returns neither, but a normal Point3, which is a normal floating-point position. Point3D is double (correct me if I’m wrong)

This looks a bit complicated and ugly, use this instead:

car.setY(car, dt*self.speed )

discourse.panda3d.org/viewtopic.php?t=1228