Since you're re-creating and animating your cube inside your Geometry Nodes and the original is stationary, the Track To
constraint on your Camera is not doing anything. On that constraint modifier, there's an option to follow a vertex group as well, maybe we could create a vertex selection out of the animated cubes inside GN and tell the modifier to follow that? Unfortunately, that's not possible unless you apply your GN modifier and destroy its procedurality in the process, since GN cannot create vertex groups, not exactly (for a more detailed explanation as to why not, you can take a look at this answer).
Still, there's a possible workaround for that vertex group idea:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/rtMCm.gif)
- Create a new object, a plane for example. Let's name it TARGET. We need only a single vertex, so enter into Edit Mode, select everything, M (Merge) > At Center.
- That single vertex still selected, create a vertex group out of it (Ctrl+G). Let's name it FOLLOW.
- In your main Geometry Nodes setup where all the animation is happening, turn the cube you want to follow into an instance, either by ticking the As Instance option on the
Object Info
node, or by using a Geometry to Instance
. Then, using a Store Named Attribute
node, capture its Position. I named the attribute LOOKAT.
- Add a Geometry Nodes modifier to your TARGET object. Get the position information we captured in the main setup into this one via a
Sample Index
node, and use that to Set Position
of our single vertex.
- Finally, on your Track To constraint of your camera, choose TARGET and FOLLOW as the object and vertex group, respectively.
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/x2HvK.png)
In summary, your main GN setup will continuously capture your cube's position and write it down as an attribute named LOOKAT. Then your TARGET object's GN setup will take that and use it to move its single vertex to that position. Since we're not creating new geometry in that setup, our vertex group will not be lost, and can be used in our camera's tracking constraint.
Since these movements are all happening in the local space, you might wanna parent your TARGET object to your main GN object in case you'd want to move or rotate them.
![](https://cdn.statically.io/img/blend-exchange.com/embedImage.png?bid=E0EsxAOw)
Update, answering OP's question in the comments as to how to set this up for an object generated inside the main GN modifier:
- When you turn a geometry into an instance, the "origin" of the instance will always be created at $[0,0,0]$, so if you do that after moving it with
Set Position
, its origin will stay there while the mesh moves around. Since the Camera is following the position of the instance, not its mesh, it won't move either. Simply putting Geometry to Instance
right after the Icosphere
node will prevent this:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/HjkHe.jpg)
- The other important part here is the
Sample Index
/Transfer Attribute
node. When you use Join Geometry
, the merging objects will get their indices according to the order of their noodles from top to bottom. In your case there are three objects going in: Bezier curve, Icosphere, and Cube. Bezier curve is not an instance, so it doesn't get an instance index. In your setup you happened to link the Icosphere below the Cube, so it gets the second index, $1$. Which means you need to tell that to the Sample Index
/Transfer Attribute
node in your target GN setup:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/d5Qyp.jpg)