So basically I want every 1-5 seconds a coin is spawned in one of 3 positions
This is how I wanted to do it, this is game mode part, every 1-5 second a new value for coin position is generated
Now this is spawner blueprint, what I want to happen here is that every 2 seconds a coin is spawned, and depending on the coin position value it can spawn in one of 3 places. But no coin is spawned.
Uncheck “looping” in your Set Timer nodes. These timers call the events containing them so they will loop on their own. Either that or set the timers only once with “looping” on, in Begin Play or some other sort of Init(), to loop the event. Also look for “Switch On Int”. It’s a better way of doing what you were trying to achieve in the Spawn Coins event. Other than that, place some Print String nodes throughout the events to see if they’re being called and when/if they fail.
Unchecking looping didn’t help. Any other ideas?
Unchecking looping isn’t the solution, it was to prevent you from endlessly setting looping timers.
Place some Print String nodes throughout the events to see if they’re being called and when/if they fail.
its actually a pretty simple thing to accomplish and you dont need to use a timer at all (i dont think your timer would have worked anyway since its setup wrong). in the example below i made the entire script in one actor for simplicity. the process i went with was to spawn a coin every 1-5 seconds and randomly choose the location out of 3 (this is based on your setup). this script also functions by creating looping script.
so the basic idea is to create a custom event which when called is delayed, then spawns a coin, then repeats. the delay is the time between when coins are spawned so here you can use a basic random float in range. to determine the location i use a select which makes things simpler and less cluttered compared to all the checks you would have to do otherwise. for the select you just need to plug in a int which represents which option pin to use, you could also feed in this value from your game mode as in your example. with all these randoms you could also make the values variable so that you could set them on a per instance basis. you could also make the locations based on a variable as well if you wanted so you could use objects in the level or make the locations array based.
oh and the reason i said that your timers were wrong is because they call themselves and due to how you have your exe pin going to the script. the correct way to use your setup would be to have a second event (CustomEventB) coming off the event pin on the timer, then have your script connected to the exe pin of CustomEventB. even with that fixed though it still may not have worked correctly, i did a quick test and timers dont work well with random numbers (edit timers dont work with variable numbers either).
Wow, this is a lot better than my way. Thank you, Ill be using your way from now.