Making an object move with the camera?

I want an object to always have the same position relative to the camera. In this case it’s a skybox (with setDepthTest to False so that it can be a background).

I thought I would just reparentTo(, but that doesn’t seem to work. I worked around this by instead reparenting my skybox to self.render and making a task where I do self.skybox.setPos( and that works, i.e. I have my background and all that. I’m just wondering if I’m missing something about reparentTo? Should have that achieved the same effect?

Reparenting to the camera should work as intended. Just make sure, that is the right one.
Otherwise, I’ve done something similar too here

If that doesn’t help, maybe some more information or showing parts of your code wild give more insight on your problem.

In addition, perhaps check that you aren’t subsequently reparenting the sky-box to something else, and thus undoing the effect of reparenting it to the camera.

I got it working. I think I was messing with the position of the skybox earlier which may have accounted for some difficulties.

I kept around the task so that I could modify the orientation of the skybox as I moved the camera, since otherwise it’s locked and static, but anyways thanks for the help!

You needn’t keep that task, by the way: you could potentially replace it with a CompassEffect, which would update the orientation of the sky-box without requiring that it be done manually within a task.

Hey it works, awesome!

1 Like