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.
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.
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.