Excluding actors (floor) from Event Hit

Hi everyone,

This is my first question on this forum. I found everything I needed so far on various YT tutorials but this one is kinda tricky and I’m walking in circles for a week or so already.

I am making a simple conceptual game where the player’s character is running around constatnly loosing health and when it hits some of the objects, the character is healed but at the same time the hit object is destroyed.

Here is the graph of what I’ve done so far to make this mechanic happen:


The player is healed and the object is destroyed, but the floor that the player is running on is also destroyed (e.g. when player jumps). How do I exclude the floor form being destroyed when hit by player?

Thanks in advance!

EDIT: Forgot to mention that ‘Heal Player’ is my Custom Event.

I was trying to think of a way to do it with different collision, but you always have to collide with the floor.

So maybe add a tag to all your floor actors. Then take the “Other” pin and call ActorHasTag followed by a branch node. The false node should connect to “Destroy Actor”.

Try to set tags in the BP so you can reuse them and not worry about setting the tag. But if you have static meshes for the floor dropped directly into the level, you’ll have to update those in the outliner. For those, you can select them all in the outliner, right click and select “Edit Selection in Property Matrix”. Then you can add the tag to everything at once. The downside is you’ll have to remember to do this for all your floor assets going forward if you add more. This is why it’s best if they are BPs. If you set it in the BP, then you don’t need to worry about it if you use the asset again in the future.

You can do the opposite instead where you add a tag to whatever you want to be able to destroy. You’ll have to decide which way is best for you.

1 Like

Thanks for the quick answer!

When I set it like this:


it works, but my player character is destroyed on hit then, which is not what is inteded.

When I tag all the other actors, and reverse the branch node:


no destruction happens… I suppose it has something to do with the ‘target’ node on Destroy Actor function.

In both cases, you need to connect “Other” from Event Hit to the “Destroy Actor” node. Leave the rest as is. Both alternatives should work. It’s up to you which you prefer.

Best (Easiest to code) way is to apply (different) physics material to surfaces, then detect which materiel player steps on, and act on it. All you need is name of material, they all can have same physics properties.

PS.
Really useful for making different footsteps sounds. Well thinking of it, that was done by design. :wink:


@AlienRenders

You mean like this?


In this case floor gets destroyed, as if it overrides Actor Has Tag Condition.


@Nawrot

Will try this as well, thanks!

Connect the Branch, with no white execution wire, it does not do anything.

like this?


if I try that, the floor gets destroyed again

Did you give the floor the appropriate tag?

here’s the tag, I suppose it should like like this:
image

when I set it like this, floor doesn’t get destroyed (but the player does), so I believe the tag works:

That’s a component tag, not actor tag. Actor can have tags, and so can each of their components:


Alternatively, if you prefer working with components tags, ask the Hit Component instead:

2 Likes

you’re checking actor tags…while giving component tag.they’re different.
explaining it to you right now might bring you too much information.

so,instead of tag the floor,give tag to the heal objects.do you have prepared heal object blueprint?

I’d do the whole thing differently. The Hit Event can spam every frame, there’s no need to do that. Consider working with overlaps and have a pickup actor heal the player:

When you overlap an item, it heals the player and destroys itself.


This can be set up inside the player, too. Player overlaps the item, heals themselves, destroys the item. Floor are inherently not to be Overlapped, but Blocked instead. So the original problem the thread is about does not even exist.

Yep you should do like above @Everynone s method .because later you might want to exclude walls,etc…that would be endless.

Now it works like charm!


Thanks, I believe that is the solution!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.