Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Why doesn't multiple events get called on ActorBeginOverlap?

I'm making a beginner game where I spawn enemies, health packs, ammo packs randomly in an actor which is a box. This BP typically works when I use it in Level BP with BeginPlay, but now since I want to restrict it to certain areas of a level after the player enters I took this approach.

For some reason only the first event gets called, regardless of the order of events... How would I make it call all the events?

alt text alt text

Product Version: UE 4.19
more ▼

asked Dec 09 '18 at 08:28 AM in Blueprint Scripting

avatar image

9 1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

In your fSpawnEnemy, fSpawnHealthPack and fSpawnAmmoPack functions add a PrintString node that prints function name and see if it prints it - it should print the first function after 2 seconds, second one after 5 seconds and the last one after 10 seconds. Timers don't execute functions immediately, the functions will be called after X specified time. If you want to fire the functions immediately after overlap and start the timer, try something like this, I've recreated your setup and it works properly:



ahhelp.png (99.6 kB)
ahhelp2.png (31.1 kB)
more ▼

answered Dec 09 '18 at 10:56 AM

avatar image

2k 155 153 206

avatar image Kiragami- Dec 09 '18 at 07:26 PM

Hello, thank you for helping.

So I tried with just Print String and it works, but when I do spawns it doesn't. When I connect the Spawning after Print String and do it like how you did 'ahhelp.png', I end up getting an infinite loop on Spawn Enemy...

If I take out those Function calls before the 'Set Timer by Function Name', the program runs but it only spawns enemies every 2 seconds...

Not sure why this happens, cause this spawn code normally works in Level BP with BeginPlay. And it's why I assumed it was an issue with overlap.

avatar image Slavq Dec 09 '18 at 08:53 PM

Good, so we've narrowed down the issue.

If it results with infinite loop, then maybe something like this happens:

  1. On Event ActorBeginOverlap, it spawns a minion

  2. Minion triggers the Event ActorBeginOverlap

  3. The event spawns another minion. Back to point 1, and we have an infinite loop.

Do you want your minions to trigger this overlap event? If not, you can try casting the "Other Actor" output from the event to your minion class and progress only if cast fails. Just as a quick test, since I'm not sure how the rest of your logic is set.

Without these extra events, I suspect that something like that might happen: Every time a minion triggers the event, it restarts all the timers this way. That's why only the first one fires, the next timers are reset (counting from beginning) every time the first function is executed (when it spawns a minion).

avatar image Kiragami- Dec 09 '18 at 08:56 PM

Oh! Makes perfect sense... Now that I think about that fact I'm stupid... Yeah the reason it always worked in Level BP before was I didn't activate it through an overlap, so never had the issue of Minions spawning and redoing the loop resulting in Health/Ammo being ignored.

Yeah that was definitely the issue, it's only supposed to trigger once when the Player overlaps the area to start a survival-ish type of mode. Thank you for your help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question