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.
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
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).
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
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?
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.
Thanks a lot again, that’s great!
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?