x

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"

Multiple Event Instances Bug?

OK, here's the situation:

Note: the laser object stores a "laser terminator" variable that tells the laser what object it's ending or reflecting on.

Scenario: Laser object 'hits' (raytraces) a mirror. Some calculations are done, a new laser is spawned.

Note: this new laser's trajectory makes it hit the very edge (non-reflective) of the mirror. Since the mirror doesn't care about that (it's a non-reflective component), it ignores it and does nothing.

This new laser is stored in a map (variable local to the mirror) with the original laser as the key. When the original laser is destroyed, it activates the mirror's "OnLaserHitEnd" event, which does several things:

 1) Check to see if the laser object whose hit is ending has an associated 'emitted laser' in the map variable.
 2) If so, it destroys that actor.
 3) Deletes the key/entry in the map for the laser object

When a laser is destroyed, it tells it's "LaserTerminator" so by calling the "OnLaserHitEnd" function.

Let's call these lasers Laser0 (original) and Laser1 (reflected). When Laser0 calls the mirror's "OnLaserHitEnd" event, here is what should happen:

 1) Mirror finds Laser1 in the map using Laser0 as the key.
 2) Mirror destroys Laser1.
 2) 1) Laser 1 fires Mirror's "onLaserHitEnd" event
 2) 2) Mirror finds nothing in the map for Laser1, and therefore does nothing
 3) Mirror deletes the key/entry in the map for Laser0

Here is what IS happening, which is causing problems down the line:

 1) Mirror finds Laser1 in the map using Laser0 as the key.
 2) Mirror destroys Laser1.
 2) 1) Laser 1 fires Mirror's "onLaserHitEnd" event
 2) 2) Mirror finds nothing in the map for Laser1, and therefore does nothing
 3) Mirror deletes the key/entry in the map for **Laser1**

So it's as though the "OnLaserHitEnd" event, because it has an instance running inside an instance, fails to return to the original value passed it in the "outer" instance (Laser0) and instead continues it's loop with the inner instance's variables.

I have no idea why this is happening. I've run, step-by-step debug multiple times and come to the same conclusion: When the outer instance finishes the inner instance and returns to its flow, it does so with the inner instance's variables. Can anybody help me figure out WHY, and help me stop it from doing this? Thanks!

Product Version: UE 4.15
Tags:
more ▼

asked May 16 '17 at 04:17 AM in Blueprint Scripting

avatar image

Snipeye
3 1 4

avatar image Snipeye May 17 '17 at 02:29 AM

To avoid https://xkcd.com/979/, I've found a workaround - not a solution. Note: A lot of event things don't seem to propagate properly if they call themselves. The workaround is to trash the event and use a function instead. Sometimes the event can just call the function, but for some cases that might not work. With the function in place, all instances complete properly.

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

0 answers: sort voted first
Be the first one to answer this question
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