Having trouble spawning boss after a certain distance traveled

I am building a endless runner but I am having trouble having it so a boss monster spawns after a certain distance/certain number of tiles spawned. I have been stuck on this problem for a long *** time. If someone could help me with a instant messenger program that would be great :slight_smile:

Here is a way you can do it. In the player blueprint, create a float var to store distance travelled and create a vector variable to store last player position.
At begin play set the last player position to its current position (spawn pos)
Each frame:

  • Get current player position, subtract last position and compute that vector’s length
  • Add that length to distance traveled
  • Set last pos to current pos
  • Check whether enough distance is traveled to spawn the boss

Ooor, since you’re working on an endless runner, if the player has constant speed you can just set a timer that triggers after the (trigger distance / speed) seconds.

alright ill try this out

Ok so I have my recorded distance, Now how would I create a function that tells my boss monster to spawn after a certain distance?

So since you have the distance, you can compare it to your trigger distance every tick and if it exceeds the trigger distance spawn the boss actor.

Now you need to make sure the boss is only spawned once. One way to do that is to put a DoOnce node between the distance check and the boss spawning. Another way is to put a Gate node at the very start. It should start open and be closed after the boss is spawned. A gate node is useful to disable an entire section of code whenever you want. The gate node is best for performance since you don’t update the distance travelled once its no longer needed.

So Im kind of confused what you mean by my trigger distance every tick. This is how I spawn my floor tiles right now

And Floor Curves

The second image is how I Record the distance

Your trigger distance is the distance at which you want the boss to spawn.

So would I follow a similar design to the way I spawn floor tiles?

Well, do you want your character to stop running when the boss is there? Or to keep running and have the boss stay in front of the character?

I want him to keep running and the boss would float in front of him. Im working towards the boss attacking your character while you dodge him.

I am pretty new at this but have gotten this far with little to no previous knowledge :slight_smile: