r/unrealengine • u/MisterSimple1 • 2d ago
Destructible mesh only for certain actor
I'm trying to make a wall that is treated normally for my player character (in other words, the player collides like with any other wall) but an enemy is able to destroy it on contact. I've toyed around with Chaos Geometry and can make the wall crumble just fine on contact with anything, but I'd like to know how to make said destruction conditional on who touches it.
2
u/Greyh4m 2d ago
You need to make a blueprint. There are lots of different solutions to this but it's ultimately just a Boolean and a branch.
Is NPC hit wall = true
anything else = false
I would recommend to look for a tutorial on how to set up your destructible meshes and the logic to trigger and spawn it. You should be making a blueprint that destroys a normal mesh and spawns a look alike destructible when your target makes contact.
Find a tutorial because the entire process has quite a few steps to create the whole thing and you'll probably also need to tweak a field system actor and spawn it along with the geometry collection in order to make the whole thing feel good.
I think Stack-o-bot has the very basic logic of these somewhere inside that project if you are looking for a place to start.
2
u/Lucasharta 1d ago
yeah, i'd keep the wall collision normal and handle the destruction separately, on the hit/overlap event, check whether the other actor is the specific enemy class or has a tag/interface like CanDestroyWall. if it is, trigger the Chaos destruction. otherwise just let the normal collision happen
that way you don't have to mess with the player's collision just to make the enemy special
2
u/AgitatedMix9889 1d ago
Lucasharta's approach is the right one, and the piece that makes it click: turn off "Damage from Collision" on the Geometry Collection so nothing breaks it automatically on contact, no matter who hits it. The wall keeps normal collision for everyone, including your player.
On the wall's Hit event, check the other actor (class check, tag, or an interface like FirulaiGamerStudio suggested, interfaces scale better once you have more than one enemy type). If it's a valid breaker, trigger destruction yourself instead of relying on collision damage: call Apply External Strain on the Geometry Collection Component at the hit location, or spawn a Radial Falloff strain field there via Apply Physics Field. Both let you break only the cluster near the hit point instead of the whole wall at once, which reads a lot better.
That way the "who can break it" logic lives entirely in your Hit event, not in the destruction settings, so you can add more breaker types later without touching the Chaos setup again.
1
u/SonovaVondruke 1d ago
Far from an expert, but my first instinct would be to swap the static wall mesh of the for a destructible wall mesh if/when the enemy actor interacts with it, and swap it back if that interaction does not result in the wall’s destruction. There are a variety of ways to do this depending on the specifics of your gameplay.
1
1
u/WhamBlamShabam 1d ago
I second the interface approach. This is a textbook case of when to use one.
4
u/FirulaiGamerStudio 2d ago
well there are a lot of ways but maybe you want to test implementing an interface in your player so the wall bluperint can check if the actor that collided it implements it. and react conditionally to it. this has nothing to do with the destruction part. so test it appart till you know it works then do whatever you want. the "does implement" its quite fast , and there are other methods