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"

Overlap event handling in multiple actors

Hi everyone! I have run into an error while scripting a system for my game. The problem is that 2 actors are both trying to do something when an overlap occurs. Actor 1 is supposed to be destroyed, but then Actor 2 is trying to handle the same overlap on the same tick, but can't check the overlap anymore, as Actor 1 is pending kill.

To give some basic context:

  • I have a weapon projectile that the player shoots, this is Actor1. Has a custom collision channel called
    'playerProjectille'

  • I have an enemy with a hitbox, this is Actor2. Has a custom collision channel called 'damageableObject'

  • In the player's projectile blueprint, there's an overlap check, if it overlaps anything with "damageableObject" channel, plays explosion, sound, and gets destroyed

  • In the enemy's blueprint, there's an overlap check as well, if it overlaps anything with "playerProjectile" channel, it takes damage, plays sound, loses health etc.

The problem is that when the projectile and the enemy touch, the projectile does it's script first I guess, gets flagged to get killed, then the enemy does its check of the same overlap, but can't access the projectile anymore as it's flagged to be killed. If its done in the opposite order, maybe it would work, as the enemy's script won't destroy the projectile. BUT if the enemy is killed by the shot, it might destroy itself on the overlap, and then the projectile can't do their part of the overlap.

Can anyone help me with how this could be worked around or fixed? I set up the collision channels for future systems where the player will shoot all different kinds of projectiles from different weapons, so instead of casting to each type of bullets and weapons, and get exponentially growing code, I wanted to handle them all under "playerProjectile" collision reactions, so every enemy will know to react to every type of projectile. I also plan to create many, many different types of enemies and breakable objects, so the same goes for the "damageableObject" collision channel. You guys know what I mean :)

Any help would be greatly appreciated!

Product Version: UE 4.18
Tags:
more ▼

asked Mar 13 '18 at 06:30 PM in Blueprint Scripting

avatar image

Cubengine
13 2 2 6

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

1 answer: sort voted first

Instead of checking collisions on both sides, you could send some kind of message to an enemy from projectile about type of damage. You can do that with Apply Damage node with your custom DamageType class assigned to it. In enemy blueprint you will need to assign an OnTakeAnyDamage event, and react to information, given through DamageType pin.

You can watch a video about this system: youtu.be/MLtDgukVG94

more ▼

answered Mar 13 '18 at 07:02 PM

avatar image

STeeL835
78 5 9

(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