[SOLVED] Is there a way to lock a primitive(s) to the camera?

Hello, here is my project:
https://playcanvas.com/editor/scene/1321393
I am trying to lock the several “cylinder” primitives (as read in the hierarchy) to the camera, so that they always appear in the corner of the player’s screen. I have them positioned at the right level (even though it looks like they are not from the editor), but I need a way so that the churros/hot chocolate cylinders always stay locked in the bottom of the screen. By placing them within the player as children in the hierarchy, they move with the player, but as you look around, they do not lock/ face the same direction as the camera. If you are trying to understand what I need, I am basing this off of csSurf’s knife in the corner of the screen as seen below:


Is there anyway to do this? Thanks to anyone who can help! :smiley: .

The entity has to be a child entity of the camera entity.

I set them in the camera as children, and it still doesn’t work. Thanks for the help though, @Albertos . Is there another way to do this, maybe via script?

Can you share an example of your scene setup? Unless you are doing something really special, what @Albertos proposed is the way to go.

Here is the setup for the hierarchy:


The cylinders are what I am trying to stick with the camera. I think it has to do with the script, “first person movement.” Take a look at my project, what’s happening is quite weird. What Albertos was saying would usually work, I agree. What happens is the churros/hot chocolate move with the camera, but do not face the same direction. Thanks for the help, though, leonidas. :smiley:

Hello

Just looked at your project. There is a this.camera = null in your init function that deletes your camera which is linked to your player entity. The camera you see when you launch the project is one that is created by your first person movement script at run time and not the one that you created manually and tried to link the cylinders to.

You need to delete that code and then move that camera you have on the top to be on level with the player. After that you can align your renders to be according with that camera.

2 Likes

Oh okay, thank you nasjarta. I will do that now! :smiley: . I am afraid it is still not working… :thinking:

The entities are no child entities of the camera entity at the moment.

Oh, okay there we go. I must have taken them off in confusion. Thanks for spending your time to help! :smiley: .