Endless runner sidekick character

I’m making an endless runner and I want to introduce a sidekick character, like in Donkey Kong Country series, in which Diddy Kong follows Donkey Kong.

My endless runner has a terrain like Zombie Tsunami: normal level street, high level street, and no street at all (a gap).

My sidekick should follow the main character perfectly (and not like the zombies in zombie tsunami that most of time are falling in the gaps). It only will fall into the gaps if the main character does it.

I though two ways of achieving this:

  1. When the user hit jump button, wait X (seconds? frames? distance?) and do the same jump.

  2. Put a collider2D in the front of the sidekick and, when is not colliding with the ground, do a jump. But then I see no way to tell him to land (not all gaps have the same length). This way will create a perfect sidekick that don’t follow the main character but the path. I don’t care, it also works for me.

Is there another way to do this? What do you suggest?

I’m assuming your sidekick is using all the same physics that your main character is?

Anyway your first idea sounds fine. As long as you workout the correct timing for the sidekick it should work fine.

Basically just think about this… does your sidekick keep a persistent distance from your player? If yes things are much easier.

If your player moves at 1 unit/meter per second and your sidekick is always 1 unit/meter behind then you simply just make the sidekick wait 1 second. (then whatever effects/physics you apply to your player do the same to the sidekick)

If the distance between player and sidekick vary then your calculations become more complicated and you will have to work out everything for the sidekick itself. But if its constant then it should be quite easy just to duplicate what the player is doing.

(if you do get it working, throw in a vid link to your next reply. Would be nice to see what you got working)


If your sidekick is mimicking your character’s motion exactly, you could simply record the character’s actions as you process them, and then have the sidekick duplicate them after an appropriate delay. If you run the sidekick on the same controller as the player, the sidekick will then mimic the actions. This is basically just the technique used in game testing where you record the player’s input and then play it back later to see what happened.

Every time you process a keypress from the player, record the action that happened and the Time.deltaTime.