So ive been screwing around with a camera that will follow my ship for a while. I know i could just parent it to the ship but its all ugly and 2d looking. I need to stick a ray out the rear of my ship that rotates with the ship so the end of the ray is always directly behind the ship regardless if the ships hpr. i also need to parent the camera to the end of the ray, is that possible? please help ive been stuck on this for much longer than i should be.
You don’t need a “ray” in the sense of a collision ray. You just need a couple of nodes.
Create a root node that is the parent node of both your ship and your camera. Attach the ship and the camera to this node. Set the pos on the camera to the distance behind the ship you’d like it to be.
Now when you move the ship, apply the hpr to the ship itself, but apply the pos to this parent node. The parent node will move both the ship and the camera together.
Is there a specific reason that method would be better than simply parenting the camera to the ship?
It separates the ship’s rotation from the ship’s position. Now you can rotate the ship without moving the camera too.
Aha missed that constraint. In that case, what about a compass effect told to both face the ship (pseudo billboard) as well as position itself relative to the ship? I’ve never used a CompassEffect to maintain a position, but after reading the Panda API, it seems possible. Would this be a time to use it?
Uh, maybe. But that’s going so far out of your way. Why not just create separate nodes to isolate position and hpr? That’s the whole point of having a scene graph in the first place, to make abstractions like this easier to set up.
Gotcha, fair enough. Thanks!