Spawning Boss Monster After Certain Distance

Im making a endless runner and im trying to make a boss spawn after a certain distance. Ive been following the tutorials for the endless runner on youtube and ive been trying to spawn him in the same way that I spawn in right and left turns, but I seem to have a problem.

This is my script for adding the boss monster, and im trying to make him spawn in after 10 tiles at the moment.
My problem at least what I think is that after I spawn a right or left turn, it resets the strait run to 0 which means following my logic it will be impossible to reach 10 strait tiles. Any way I can get around this? Keep as simple as possible im new to this

From what I gathered you want to spawn him after 10 total tiles, no matter if they are turns or a straight path.

Would creating a total tiles traveled float be out of the question? You could just routinely add onto the float and spawn the boss if it exceeds certain values.

Thats an awesome idea, now… how would I implement/DO something like that. Im quite new, im just willing to learn and I have this idea that has been nagging at me and I want to get it done :). Im not sure how to make it so I can count the total number of tiles. See in the future I want to be able to change it so after the boss the level will change to some sort of other scenery and other stuff.

Exactly the same way as you implemented the “straights” variable. Just add another 1 called “tilesTraveled” and give it a ++ at the same time as the straights and just don’t reset it until the boss has spawned or whatever other conditions you want.

Im having trouble implementing this, what do you mean by giving it a ++, and where would I add in the tiles traveled? I tried something similar and when I stop it from resetting back to zero my curves just start to overlap constantly.

++ means +1. Exactly the same way and same location that the “current straights” is getting done but then also give a +1 when it spawns the curves too. You don’t want your current straights variable to not reset because you are using that for other logic

You could hook a DoN node before/after your Spawn Tile Action then use the counter as the tiles until boss spawn. Say you make it 20 and you use a branch to flow control it. If counter = 20, spawn boss, reset counter. So every time you spawn a tile the DoN will execute then +1 the counter. If it doesn’t equal 20 branch accordingly

Hey dedrick so I tried hooking up a DoN node after the Floor Tile Node and before the Branch Node in the first image, but it doesnt seem to work… help would be appreciated

I tried it out and I figured out why it isn’t working. DoN doesn’t work in functions but it does work outside of functions.

And the result

So what you would need to do is create an Int input value on your Add Tile function and feed the counter into it. Toss the DoN before Calling Add Tile. Do the branch logic inside the function and have a bool output to trigger the reset counter. I used a Select Int node to set the Bool output, which feeds into the Branch outside of the function

Hope this puts you on the right path!

Hey DEDRICK, So i did EXACTLY what you did but instead of the print string nodes I had my Spawn BossMonster Tile instead but it does not work. Could the problem be that I am resetting the straights after a certain number of tiles?

It’s hard to say. The DoN should be neutral to either Straight or Curve tiles because it is just counting how many times you have spawn tiles. Even if you reset the straight count, the DoN counter should still be going. I would throw some print strings in to see what is really happening with your “Current” and DoN counters

Hey Dedrick, so I have been stuck on this for a while, would you be willing to chat with me on some kind of instant messaging service to help me through this?