Tutorials – UE3 Physics
About : This tutorial will explain the reader how to apply basic physics to a piece of geometry.
Target Audience : Unreal Engine 3 users – Beginners
Platform : Unreal Engine 3
Last Update : December 2010
Creating a physics object is quite easy. Find yourself a nice a and small Staticmesh in somewhere, and add it to the world somewhere as a regular Staticmesh by holding “s” on the keyboard and clicking somewhere, or dragging it in from the Content Browser. Then, rightclick the Staticmesh you’ve just added to the world, and go to Convert – Convert StaticMeshActor to KActor.
Now boot up the game and shoot the mesh. It will move!
Meshes that do not have a Simplified Collision defined, cannot be transformed into Kactors. If the mesh does not move when you shoot it, the first thing to check is its Simplified Collision.
The smaller the mesh, the less it weighs. The size of the bounding box is the mass of the object. Try scaling up the mesh you just made, and see if you can still move it in-game. You can’t. The larger the mesh is, the more force is required to move it. This is where Physical Materials come into play. Physical Materials allow access to properties such as the weight and friction of an object.
A Physical Material is created and stored in the Content Browser, and stored in a package. Go to the Content Browser, and rightclick an empty space in the central panel. Pick Create New Physical Material. Once created, open up its properties by double clicking it.
These are the properties I used the most:
Density – This is the weight, the smaller the number the more easy it will be to move it.
Friction – Lowering this number will reduce the friction the object has. A low value will make the object behave as if it is on ice, gliding around.
Impact and Slide Effect – What particle effect to play when the object crashes into something or glides around.
Impact and Slide ReFireDelay – The length of the delay between each Impact or Slide event.
Impact and Slide Sound – The sound to play for these events.
Impact and Slide Threshold – How sensitive it is. How likely it is to activate these events as it moves around.
Restitution – How much the object bounces. A value of 1.000000 would make it behave as a gummy ball.
You can apply a Physical Material by entering it in the PhysMaterialOverride property, found in the properties of the KActor in the sections DynamicSMActor – StaticMeshComponent – Physics.
If you wish to use Impact and Slide Effects, it is crucial you also enable bNotifyRigidBodyCollision.
Also, you may want to take a look at the Mass properties found in the properties of the Static Mesh in the Content Browser. Double click a Static Mesh – Body Setup – MassScale. Tweaking this value gives additional control over the weight of the Static Mesh. PhysMaterial, found in the same area, also allows you to assign a default Physical Material to the Static Mesh.
Additionally, these same Physical Materials are also used to change the footsteps and weapon impact sounds and particles. By applying a Physical Material to a Material, you can alter those and make a sand material sound like sand for example.
Dynamic Static Mesh Actors
Since Spring 2010, regular Staticmeshes can temporarily transform themselves into KActors. In the properties of a Static Mesh in the Content Browser, there is a property bCanBecomeDynamic.
If this property is on, any regular Staticmesh actor will automatically transform itself into a Kactor as soon as a force is applied to it, and it reverts itself back to a Staticmesh as soon as it comes to a halt. This improves performance, as the object does is only rendered as a dynamic physics object when it actually moves.
In the Actor Browser navigate to RigidBodyBase and expand it. These actors apply a force to physics objects.
Add a RB_RadialForceActor to the level, it applies a force in a spherical shape. Open its properties.
The most important properties are:
bForceActiv – If it is on or off. You can toggle this on and off via Kismet during gameplay.
ForceRadius – How far its effect reaches
ForceStrength – How strong it is. A higher value means it will apply a stronger force. A negative value will make it act as a magnet, and attract things.
The other Force and Impulse actors are similar to this RadialForceActor.