Book Image

Unreal Engine Physics Essentials

By : Devin Sherry, Vladimir Alyamkin, Katax Emperore
Book Image

Unreal Engine Physics Essentials

By: Devin Sherry, Vladimir Alyamkin, Katax Emperore

Overview of this book

This book gives readers practical insight into the mathematical and physics principles necessary to properly implement physics within Unreal Engine 4. Discover how to manipulate physics within Unreal Engine 4 by learning basic real-world mathematical and physics concepts that assist in the implementation of physics-based objects in your game world. Then, you'll be introduced to PhAT (Physics Asset Tool) within Unreal Engine 4 to learn more about developing game physics objects for your game world. Next, dive into Unreal Engine 4’s collision generation, physical materials, blueprints, constraints, and more to get hands-on experience with the tools provided by Epic to create real-world physics in Unreal Engine 4. Lastly, you will create a working Vehicle Blueprint that uses all the concepts covered in this book, as well as covering advanced physics-based topics.
Table of Contents (15 chapters)
Unreal Engine Physics Essentials
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

The 2D and 3D coordinate systems


In Unreal Engine 4, the use of 2D and 3D coordinate systems are used to determine the positions of actors in our game world. In a 2D coordinate system, we can determine an actor's position based on the X and Y axes, left-right, and up-down respectively. In a 3D coordinate system, along with the X and Y dimensions, we can determine the actor's position based on the Z axis: the inclusion of depth.

In Unreal Engine 4, the 3D axes are labeled differently, as displayed in the preceding image. Instead of the "up" axis being the y axis, in Unreal Engine 4, the "up" axis is labeled as the z axis. The "forward" axis is then the y axis instead of being the z axis, as depicted in the preceding image.

It should also be discussed that Unreal Engine 4 uses a left-handed coordinate system, which means that the positive direction for the X axis is on the right-hand side, the positive direction for the Z axis is upward, and the positive direction for the Y axis is forward. In the left-handed coordinate system, the positive rotation of an axis is always in the clockwise direction. We can see this reflected in the transform section of the details panel when an object is selected and is either moved or rotated.

In Unreal Engine 4, the X axis is labeled as a red-colored arrow; the Y axis is labeled as the green arrow, and the Z axis as the blue arrow. In the editor, you can toggle the transformation type of a selected object between translation, rotation, and scale by either repeatedly pressing on the spacebar or by toggling between the W (translation), E (rotation), and R (scale) keys. The viewport depicted in the preceding image is known as the perspective viewport. This is the only 3D viewport in Unreal Engine 4 and can be accessed using the Alt + G shortcut. When you work on a 3D game, Unreal Engine 4 offers three 2D viewports: the top, side, and front perspective viewports to take advantage of when you place objects in your game world.

The top perspective

This perspective presents the 3D world from a top-down view (using the 2D coordinate system) with the X and Y axes that is similar to the previous image of the 2D coordinate system, where the Y axis represents up and down and the X axis represents left and right. This perspective can be accessed with the Alt + J shortcut or by clicking on the drop-down list labeled Perspective and selecting the Top option, as shown in the following screenshot:

The side perspective

This perspective presents the 3D world from a side view perspective with the Z and Y axes using the 2D coordinate system. It effectively looks at the world from the left-hand side to the right-hand side. In this perspective, the Z axis represents up and down, whereas the Y axis represents left and right. This perspective can be accessed with the Alt + K shortcut or by the same method that is used to access the other three perspectives.

The front perspective

This perspective presents the 3D world from the front perspective with the Z and X axes using a coordinate system. It essentially views the world from the front to back side. In this perspective, the Z axis represents up and down, whereas the X axis represents left and right. This perspective can be accessed with the Alt + H short cut or by the same method that is used to access the other three perspectives.

Lastly, let's briefly discuss how rotation works in 3D programs, such as Unreal Engine 4. In the real world, the three different types of rotation of an object are Yaw, Pitch, and Roll. These rotations are defined as follows:

  • Pitch: In Unreal Engine 4, this is defined as the rotation of an object about the Y axis.

  • Yaw: In Unreal Engine 4, this is defined as the rotation of an object about the Z axis.

  • Roll: In Unreal Engine 4, this is defined as the rotation of an object about the X axis.

In the real world, the pitch, yaw, and roll rotations of an object can be visualized by looking at how a plane can rotate, as shown in the following image: