2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
We have already completed the production of the field system (【UE5.1】Chaos physics system foundation——02 Application of field system_ue5) and the production of bullets ([UE5.1 Character Practice] 16-Firearm Shooting-Aiming), now we are going to achieve the effect that the character shoots bullets to destroy the stone pillars.
1. Open the bullet blueprint "BP_Ammo_5mm"
Find the force field "BP_ForceField" used to destroy the stone pillars
Move "BP_ForceField" to the "Sphere" level of the spherical collision component
2. Open "BP_ForceField" and add a custom event in the event graph to trigger the field system
Add three public floating-point variables named "StrainMagnitude", "ForceMagnitude" and "TorqueMagnitude" to control the tension, radial force and torque of the field system. The default values are set to 500000, 10000 and 10 respectively.
The variables are used in the following positions:
Select the spherical collision component "Sphere", and then uncheck "Generate overlap events" to prevent the bullet from overlapping with the component.
3. Go back to the bullet blueprint "BP_Ammo_5mm" and set the trigger field system when the bullet hits
Regardless of whether the bullet hits a Character or not, the event "Activate" will be activated
Scale the child Actor "BP_ForeceField" a bit larger
4. Delete "BP_ForceField" in the scene
Select the geometry set in the scene and set the check overlap event
Now we can see that we can destroy the stone pillars with bullets.
We can change the distance of the broken rocks by adjusting the value of "ForceMagnitude"