Camera attached to the point of view


#1

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.


How to make an object follow the camera and stop following when that object collide with a wall or another object or when camera activates another object?
#2

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:

Click here to see example in action

Step by step

  1. 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
  2. Open the hierarchy tab to find your camera item
  3. Click the ‘Attach’ button on the item you want to make a child
  4. 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

ParentPhysicsItem


#3

This does not seem to work anymore. :confused: (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 :pray:
Thanks


#4

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).


#5

Aahh! :grinning:

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.


#6

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 :slight_smile: