How to make the camera like in subway surfers?

I have been looking how to do this for months and I can’t find it so I decided to ask here. I’ve been trying to make an endless runner similar to subway surfers but I’ve encountered a problem. I don’t know how to make the camera only stay on the same z axis (so when character jumps it will stay) and also I don’t want the camera to go fully to the left when my character does and right. Any help appreciated.

See if you can adapt this to your needs:

Not sure how you’re switching lanes, I am faking it here. The crux is in the springarm offset, and it living in world space:

If the level design has verticality, trace downwards to get distance to the ground rather than using a flat (here, 300) value for Z.

Close enough?

1 Like

Thank you for that comment. That is exactly what I was looking for but as I am a beginner I don’t understand how you got that yellow set in the middle that debug. I also have a similar method of using lane 1,2 and 3 but they are integers which doesn’t allow me to connect to the green set. Thank you

Drag a wire from the springarm component and:

image

connect to the green set

They’re enumerators - really convenient stuff. But you do not need it, see below.

I also have a similar method of using lane 1,2 and 3 but they are integers

Use them then:

Or even simpler, like so:


You said you’ve been at it for a couple of months - not sure what to suggest to fit into your existing systems. Next time you post, consider telling a bit more about how things work - chances are you get a more suitable answer, and faster to boot!

Good luck!