I have been working on a flying game for some time and I have hit a snag. Currently, I have a simple script set to delete my FlyingPawn when it touches the ground, and have it respawn after 2 seconds (for test purposes). Now, I want to have the plane explode into bits, accompanied by an explosion and smoke, and have the ship respawn after 5 seconds. Unfortunately, the explosion blueprint I built is not firing when my pawn hits the ground, and I can’t seem to get the destructible mesh to work. Here is my progress:
The explosion script. This is supposed to move the explosion (which is on the map somewhere) to the pawn’s location, then trigger the explosion, radial force, and smoke. However, this is not activating at all…
The destruction script. Very basic right now, but I want to flesh this out. I tried adding a delay to see if that was the cause, but this is not the case.
The respawn script. Perhaps having the gamemode trigger the explosion is the way to go…?
I don’t think you can use the destructible mesh option on meshes that have a skeleton like with a player pawn. I think that option works only for static meshes. I think an animation of the plane has to be played instead when it hits the ground.
The player pawn is a static mesh.
oh? so is the pawn scripted to move with AI behavior or does the player control the pawn?
The explosion script probably doesn’t fire because it never hits anything, you’ll need to fire the event in another way.
Yes, you can keep a reference inside the GameMode to the explosion actor, basically get it, cast to it and set it to a variable at BeginPlay. Use maybe a custom event to fire off the explosion inside the explosion script. So then when player Hit you can fire that custom event on there from the player, using the variable stored in the GameMode to the explosion, in stead of using EventHit on the explosion script. You can send location value through from the player. No need to cast to the player inside the explosion script either.
For destroying the player, you’ll need to delay that because once the actor gets destroyed, it’s gone, there’s no more mesh to blow into pieces. Give a short time for the explosion to take affect, and then destroy the actor to get rid of it and spawn the new one.