Bullet Penetration and Projectile Physics

page 1 2 3 4

13

13_1

Set the CollisionComponent's "Return Material on Move" property to true. This is in the advanced properties of the collision section, you will have to first show the section before seeing the property.

14

In the content browser, create 2 physical material assets. In the tutorial these are called Physmat_Concrete and Physmat_Wood.

Open a material in the material editor. If you included Starter Content in your project, you can find M_Concrete_Poured for example. Change its Phys Material property to Physmat_Concrete.

Repeat for a wood material eg M_Wood_Pine.

15

15_1

Now in the FirstPersonProjectile blueprint, temporarily add a Print String node which prints the physical material at the beginning of the OnProjectileBounce event.

This is only to test that the previous steps have been done correctly.

16

16_1

Add two objects to the level with the corresponding materials. Test that the physical material is printed when the objects are hit.

17

17_1

Add a Structure asset to the project (Blueprints->Structure). In the example this is named PenetrationDataStruct.

Add 5 float variables to the structure: JoulesPerCM, ImpactAngleCoefficient, ImpactAngleConstant, VelocityCoefficient, and VelocityConstant.

Add a DataTable asset to your project and add 2 rows. The row names correspond to the names of the physical material assets created earlier. Some example data values are pictured.

18

18_1

In the FirstPersonProjectile blueprint, GetNewSpeed function, add a section which varies the JoulesPerCM based on the Physical Material hit. A local variable is useful for the scenario that no match is found.

You may now test that the projectile loses energy differently depending on the material penetrated through.

19

19_1

Create an AngleBetweenVectorsd function in the FirstPersonProjectile blueprint as pictured.

20

The formula to find the chance of penetration is pictured. In this case clamp is intended to restrict values to the range of 0-1.

Create a function named DecideWhetherToPenetrate. It should carry out the pictured formula and return a boolean.

21

Insert the DecideWhetherToPenetrate function into the event graph. You should now be able to test that each aspect of the function works correctly.

page 1 2 3 4