I have this turret in my game, and it has a destructable mesh component so it will explode if it is shot at by the player. I have the turret set up to shoot at the player once every second. However, after the player destroys it, and it explodes into 50 pieces, the projectiles are still coming out of the gun location. Since DMs dont have their own blueprints, how can i check through the turrets blueprint whether or not the turret was destroyed?
Not sure, but maybe you can try to check the change in the bounding box to check it.
i cant find anything. Anyone know how i can do this?
You can start trying with this https://docs.unrealengine.com/latest/INT/BlueprintAPI/Collision/GetComponentBounds/index.html
im not really understanding what this node does from the documentation. what is the “box” that this nodes referring to?
You can use this node or this one if is not a blueprint and is just an actor GetActorBounds | Unreal Engine Documentation
Here is just an example in the level blueprint, you can check when the bounding box change, so the mesh changes and this mean it was destroyed. This is a bounding box [Minimum bounding box - Wikipedia][2]
Destructible Components do have events you can bind to such as On Component Hit or On Component Fracture. For example, if you simply wanted to disable firing when it gets hit by a projectile you could:
OnComponentHit → Hit Ref → Hit Actor → Cast to Your Weapon Projectile → Disable Firing.
Moreover, if you wanted to get fancy you could get the Destructible’s Physics Volume and bind to things like OnTakeAnyDamage.
Here’s another way to do this.
The “On Actor Fracture” and “On Component Fracture” nodes are nice, because they fire when and only when the destructible mesh actually shatters, and you can ‘bind’ events to them that do whatever you want to do when the mesh breaks. However, the Blueprint events associated with these nodes only give you the location and direction of the fracture event as outputs to use when calling bound events, NOT a reference to the destructible actor itself. (See image below.)
If each destructible you’re using is its own Blueprint actor, this shouldn’t be a problem – just bind the event to “On Actor / Component Fracture” nodes with that Blueprint itself as the target when you Begin Play:
If your destructible meshes aren’t blueprints, though, you may need some way to find which mesh shattered when the event fires.
I did that by storing an array of my destructible meshes on “Begin Play” and then binding an event to “On Actor Fracture” for each one that looks for the closest destructible mesh to the fracture location each time the event fires, and tags that mesh as fractured. This seems to work well as long as you don’t have destructible meshes very close together.
(For reasons probably relating to the nature of for loops and actor references, trying to get the Target you’ve bound an event to at the time the event fires always seems to return the last actor to which that event was bound, rather than the actor actually triggering the event.)
Here’s my Begin Play setup for an “Event Controller” blueprint that handles all destructible mesh events…
…and here’s the Macro I wrote to find the nearest actor by to a location from within an array of actor references. This could also be a function if you’re more comfortable with them.