Trying to create a simple "Camera Follow" script

Daniel Eichler (Polatrite) 4 years ago updated by Lazlo Bonin (Lead Developer) 4 years ago 2

What should be happening:

On start: Save the difference between the Player and Camera positions as Offset.

On update: Move the camera to be at the (Player + Offset) position.


There are two things wrong with the above, one in the "Start" section and the other in the "Update" (or Late Update).

In the start: subtracting Player's position from Camera gives a difference of (0,0,0), even though they are approximately (20,23,0) different. I added a hardcoded add (20,23,0) for now.

In the update: Player's position is getting permanently incremented, at least as far as the flow graph is concerned. This causes the camera to just shoot upward forever, instead of matching the position of the player, + the offset.

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

This seems like something simple - maybe a pass-by-reference error on my part? But I just can't figure out what is going wrong.


Hi Daniel.

I'm sorry you're having this issue. Your graph is good, and it should definitely be working. 

This is actually a minor bug that's a major oversight from me. The values in the game object inline fields, for example here PLAYER and Camera, get ignored and are replaced by the game object that owns the machine instead.

This will definitely be fixed in v.1.0.1.

In the mean time, you should be able to use an external literal unit instead:

Also, here's a tip for your graph: you don't have to connect the control ports when you just need the return value of a function. For example here, the subtract and add nodes don't need to have their arrow connected:

And while Subtract from the Vector 3 class is a perfectly valid choice for this, Bolt also has the whole range of math operations available in Math/Vector 3. The main advantage of these is that they have a better icon, documentation, and don't even have a control port at all:

Again, I apologize for this silly bug and it will be fixed for the next version.