In this post I'm going to show you how to create latent Blueprint nodes that…
One can best describe the Radial Impulse as a bomb explosion, emitting force from it’s core to all nearby objects.
Creating the necessary parameters of the “Bomb” Actor
Create a class which inherits from Actor. To create a Radial Impulse we need:
- The origin of the impulse
- The radius of the impulse
- The strength of the impulse
- The impulse fall off distance (this describes how distance affects the total impulse)
The origin of the impulse will be the location of the Actor we will create. I will expose the radius and strength in the editor so we can tweak the values if needed. Switch to the header file of the Actor you just created an type in the following variables:
In this case, I will manually place some Actors near my “Bomb” Actor – this technique is just for demonstration purposes. If you wanted to simulate a bomb you should perform a sphere sweep and then store all the hits into the TArray seen above.
Creating the logic of the “Bomb” Actor
Switch to your source file and in the BeginPlay function, type in the following code:
Setting up the final values
After doing all the above, create a Blueprint based on the C++ class we created above and place it anywhere in your map (I use the FirstPersonExample map in this tutorial). Then:
- Near the placed Actor, place some cubes with the option Simulate Physics set to true
- Set up the radius of the impulse you want
- Set up the strength of the impulse you desire
- Add each nearby actor to the NearbyActors array
Here is a screenshot of my Editor after doing all the steps:
If you click on simulate, you should see a radial impulse applied to the nearby cubes. In case that didn’t happened, tweak your radius and strength a bit!