Getting the camera to follow an object

How would I get a camera to follow a moving cube. The cube is controlled by arrow keys? would lookAt(); work, if
so what parameters would
i put in that method?

You should use ofNode and setParent. A camera inherits from ofNode, it should be no problem. Have a look in the examples, there is one with multiple cameras.

This other example also shows how to add child nodes to a parent node,

I’ve looked and I don’t really understand how to use the nodes. Is there not a method that can be used ?

What did you not understand exactly? what did you try? In the linked example it should be clear what a node is. And the camera example does more or less what you are asking. Can you be a bit more precise? otherwise it is difficult to help you.

Right, I’ve had another look and I think I understand what a node is. My confusion stems from how it relates to the rectangle. The only methods I can see in the example that are camera related are cam.begin/end nothing else. If I place my rectangle inside these methods it allows me to control the rectangle viewing angle with a mouse. I would like to be able to view the rectangle from behind and then follow it when it changes direciton. Sorry if I misunderstood your point


Simply look into the examples, like the cameraParentingExample , :slight_smile: .

PS : I reply here as it seems like you have duplicated a thread.

Hope it helps.