Make an object follow the player and the camera follow that object

I want to be able to make levels that are very different without having to recreate a new player character every time just so that I can change the camera. I’ve seen it suggested to make an object that follows the player and then have the camera in the object instead. Then I just have to create a new follow object every level.

I have not been able to get an object to follow my player though. This is what I’ve tried based on suggestions online but it is not working, the block (which will be something less noticeable later) doesn’t follow.

Any suggestions?

check out Page Help> Examples

I appreciate that I have it working better now but do you know if there’s a way to make the following object more stable? It follows my Player and it makes the camera follow but if my Player stops the object zooms back and forth causing the screen to move back and forth (a little dizzying)

I tested my own link and apparently the movement keys don’t work, they do when i’m working on it and testing it.

Hey @mattison, I just added a camera object example to the examples page here:

It uses a camera object like yours, but I’m using a different approach to make it smoothly follow the player.


I get the behaviors for the most part but what does the Once, number 0 and the Alpha accomplish?

It makes the object invisible.

oh duh! Thank you :slight_smile:

I did the following camera in my class and it’s working for almost everyone. One student though with his camera once he adds the Y direction it zooms all over the place. Did Y get done incorrectly, or is his level just too big? It doesn’t seem like that’s the issues since other students are using the same behaviors and have large levels and it works.

Here’s his game

Hey @rmattison - there are two changes needed to make it work as expected:

  1. There are two cameras that are fighting for control, remove the one in the Player (dog) object.

  2. The Extract blocks inside the Camera object are extracting the x and y values from the wrong object. This is not your student’s fault - this is a bug stemming from the fact that there are two objects named “Object 7583”, and the camera is attempting to follow the incorrect one, which is a random ground block. To fix this, give the player object a meaningful name, e.g. “dog”, then update the extractors in the Camera.

With these two tweaks it works great :slight_smile:

Thank you! I did tell him to delete the players camera but I guess he only thought he did. Never would have caught the random block problem.

I have another student whose camera is floating up instead of following him. I looked for the same errors the previous student was having problems with and it’s clearly something different that I haven’t been able to figure out.

Are the Axes flipped?

the Y and X axis, no they’re connected to the correct position.

@rmattison It looks like the camera is increasing the y distance instead of decreasing it. Try changing the y comparison Expression to A+((B-A)*.04)

( note the swapped A & B )