Collisions

Objects in Unreal Engine have collision properties that can be modified to design the behavior of the object when it collides with another object.

In real life, collisions occur when two objects move and meet each other at a point of contact. Their individual object properties will determine what kind of collision we get, how they respond to the collision, and their path after the collision. This is what we try to achieve in the game world as well.

The following screenshot shows the collision properties available to an object in Unreal Engine 4:

Collisions

If you are still confused about the concept of collision, imagine Static Mesh to give an object its shape (how large it is, how wide it is, and so on), while the collision of the object is able to determine the behavior of this object when placed on the table—whether the object is able to fall through the table in the level or lay stationery on the table.

Collision configuration properties

Let us go through some of the possible configurations in Unreal's Collision properties that we should get acquainted with.

Simulation Generates Hit Events

When an object has the Simulation Generates Hit Events flag checked, an alert is raised when the object has a collision. This alert notification can be used to trigger the onset of other game actions based on this collision.

Generate Overlap Events

The Generate Overlap Events flag is similar to the Simulation Generates Hit Events flag, but when this flag is checked, in order to generate an event, all the object needs is to have another object to overlap with it.

Collision Presets

The Collision Presets property contains a few frequently used settings that have been preconfigured for you. If you wish to create your own custom collision properties, set this to Custom.

Collision Enabled

The Collision Enabled property allows three different settings: No Collision, No Physics Collision, and Collision Enabled. No Physics Collision is selected when this object is used only for non-physical types of collision such as raycasts, sweeps, and overlaps. Collision Enabled is selected when physics collision is needed. No Collision is selected when absolutely no collision is wanted.

Object Type

Objects can be categorized into several groups: WorldStatic, WorldDynamic, Pawn, PhysicsBody, Vehicle, Destructible, and Projectile. The type selected determines the interactions it takes on as it moves.

Collision Responses

The Collision Responses option sets the property values for all Trace and Object Responses that come with it. When Block is selected for Collision Responses, all the properties under Trace and Object Responses are also set to Block.

Trace Responses

The Trace Responses option affects how the object interacts with traces. Visibility and Camera are the two types of traces that you can choose to block, overlap, or ignore.

Object Responses

The Object Responses option affects how this object interacts with other object types. Remember the Object Type selection earlier? The Object Type property determines the type of object, and under this category, you can configure the collision response this object has with the different types of objects.

Collision hulls

For a collision to occur in Unreal Engine, hulls are used. To view an example of the collision hull for a Static Mesh, take a look at the light blue lines surrounding the cube in the following screenshot; it's a box collision hull:

Collision hulls

Hulls can be generated in Static Mesh Editor for static meshes. The following screenshot shows the menu options available for creating an auto-generated collision hull in Static Mesh Editor:

Collision hulls

Simple geometry objects can be combined and overlapped to form a simple hull. A simple hull/bounding box reduces the amount of calculation it needs during a collision. So for complex objects, a generalized bounding box can be used to encompass the object. When creating static mesh that has a complex shape, not a simple geometry type of object, you will need to refer to the Static Mesh creation pipeline section later on in the chapter to learn how to create a suitable collision bounding box for it.

Interactions

When designing collisions, you will also need to decide what kind of interactions the object has and what it will interact with.

To block means they will collide, and to overlap can mean that no collision will occur. When a block or an overlap happens, it is possible to flag the event so that other actions resulting from this interaction can be taken. This is to allow customized events, which you can have in game.

Note that for a block to actually occur, both objects must be set to Block and they must be set so that they block the right type of objects too. If one is set to block and the other to overlap, the overlap will occur but not the block. Block and overlap can happen when objects are moving at a high speed, but events can only be triggered on either overlap or block, not both. You can also set the blocking to ignore a particular type of object, for example, Pawn, which is the player.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset