I’m using a collisionray to detect line of sight between two objects in my game, but I have problems with what coordinate system Panda is using to control the ray. When I call my function LOS the ray should be calculated anew, but this doesn’t seem to work. Has anyone got an idea?
That means that the ray is in the coordinate system of the model. If the ray starts at (0,0,0), then it starts in the center of the model. If the model rotates, the ray rotates too.
The code looks like it was written as if the ray were not attached to the model.
Yes, as it is now it uses the coordinate system of its parent node. But if I reparent it to the render it still does not behave as intented.
The initialization
self.ray = CollisionRay(0,0,0,0,0,1)
continues to affect the ray even after it is changed by
You can still parent the ray to your model, and then switch the coordinate system of the target to the model’s coord system. Basically, it works like this :
sourceObjNodepath.getRelativePoint(targetObjNodepath,[point on targetObj’s coord system])
so, for your problem :