I program a virtual reality game in which you have lifes. My problem is that I want to fix the lifes on the camera so that you can see them every time, for example when looking up to the sky, right or left, you should be able to see them all the time.
Hi @DanielH
you can add items with the attach feature to your camera so they move and rotate with your camera motion. This is called parenting items (you add a âchildâ to a âparentâ). Here is how itâs done:
Step by step
- If an item has physics enabled make sure it is set to static when you want to add it to another item, otherwise it wonât move along
- Open the hierarchy tab to find your camera item
- Click the âAttachâ button on the item you want to make a child
- Then click the item you want to parent this to. In our case itâs the camera
Now you have one or more items moving with the camera! Make sure to scale the items down and move them closer to the camera so that they wonât disappear in the floor when you look down.
Another cool use for this is parenting static physics items to the camera so you can push non-static physics items around your space!
Click here to see physics pushing in action
This does not seem to work anymore. (see gif below)
As soon as you attach the camera to the man, the camera is set to âFixed positionâ
You can move the camera around with the mouse, but you cannot navigate using WASD keys.
Please restore the feature show in the post above
Thanks
Hi @arivera!
Attaching the camera to another item always sets its mode to âfixedâ, so that behaviour has not changed.
To create physical interaction with static physics items parented to the camera, make sure that the camera is not a child of any other item and the only parent of the physics items.
The example above shows two different use-cases: one that has the camera parented to the human (which turns it into a fixed, non-movable camera), and one in which static physics items are parented to the camera (which has no parents).
Aahh!
I was trying to attach objects to the camera in the editor, but I could no see any attach points in the camera!
I just noticed that you are using the object tree to do this!!
Thanks for the clarification.
Sorry, I am just a newbie, so I am learning a little every day.
However, it is these kinds of inconsistencies (no attach points for the camera, the opacity in the editor is in percentage, but in blockly a number between 0 and 1, for example) that throws a newbie off for a spin.
The missing attach points for the camera are duly noted!
Right now, connecting items to the camera can only be done via the hierarchy tab as shown in the posts above, but weâll make sure to make attaching items to the camera itself just as easy as in all the other cases
Hi Stefan
The part about attaching the lives works nicely, thanks for that!
I am also looking into creating a 1st person game and trying to use a person for that, but when I move it with WASD, it moves away from the camera. What am I missing?
Cheers,
Sebastian
Hi @SebEis!
The reason why your character is moving without the camera is that the character is a child-item in the camera item hierarchy. If the camera moves, so do all child-items inclusive of the character. However, the CoBlocks you used only moves the character child-item forward, but not the camera parent item.
One way to fix this issue is to move the character out of the camera item hierarchy and position & rotate the camera forever with CoBlocks.
Check out the remixable example below to see how itâs done! In this example Iâve added two new CoBlocks scripting tabs (âCameraControlâ and âCharacterControlâ) that add control to the character while also updating the camera to place itself and look at invisible âHelperâ items. You can check out where these helper items are located in the item hierarchy.
Hope this helps!
You could also just drag-and-drop the camera onto the character in Scene Inspector so that itâs a child-item of the character in the hierarchy, and ditch the PositionHelper & PositionHelper script. The forever-turn-camera is a nice hack for âdisablingâ camera rotation via mouse @Stefan
Geoff @ TechLeap
Thanks a lot! Iâll check it out as soon as I find the time.
Cheers,
Sebastian
Hi Stefan
Thanks a lot again, thatâs great!
Cheers,
Sebastian
On second thought: turning the character with the mouse would be great, that would give the cospace a more video game - like feeling. That was in my cospaces, which I - in a not so smart move - directly deleted after seeing yours.
How did I do that?
Hey,
You responded on Sebeis question with a remix. (Jul '20 )
Is it possible to prevent your character from moving through those objects in that cospace?
Kind regards,
Cora
4 posts were split to a new topic: How to collide character against walls