World and relative transforms

The Actor class has a Transform structure. This structure has three variables, which are used to represent Location, Rotation, and Scale. The Transform structure of an Actor that is on the Level can be modified by using the Details panel or the transformation Widget that appears when you select an Actor.

In the Level Editor, there are buttons that we can use to select the type of transformation to apply to an Actor, as we can see in the next screenshot:

The 3D space is represented by three axes: X, Y, and Z. These axes are represented by colors: the color red is the x axis, the color green is the y axis, and the color blue is the z axis.

The Location variable of the Transform structure has a set of values for X, Y, and Z, which determine the position on each axis. These values are also known as the world location of the Actor. The next screenshot shows some Actions that we can use to get and set an Actor's  location:

  • GetActorLocation: Returns the current location of the Actor
  • SetActorLocation: Sets New Location for the Actor
  • AddActorWorldOffset: Uses the Delta Location input parameter to modify the current location of the Actor:

The Rotation variable of the Transform structure has a set of values for X, Y, and Z in degrees, which determines the rotation on each axis. The following screenshot shows the following rotation nodes:

  • GetActorRotation: Returns the current rotation of the Actor
  • SetActorRotation: Sets New Rotation for the Actor
  • AddActorWorldRotation: Adds the Delta Rotation input parameter to the current rotation of the Actor:

The Scale variable of the Transform structure has a set of values for X, Y, and Z, which determines the scale on each axis. The following screenshot shows the nodes that are used to get and set an Actor's scale:

When a Blueprint has Actor Components, the transforms of those Components are known as relative transforms, because they are relative to the Component's parent. The next screenshot shows an example of Components. DefaultSceneRoot is a small white sphere, which is hidden in the game and used to store the Actor's position in the world. It can be replaced with another Scene Component.

Below it, in the Component's Hierarchy of the screenshot, there is a Static Mesh Component named Table, and below the Table Component in Hierarchy, there is another Static Mesh Component named Statue. The transform of the Table is relative to the DefaultSceneRoot transform, and the transform of the Statue Component is relative to the Table transform. So, if you move the Table Component in the Viewport, then the Statue Component will move too, but if you change the relative transform of the Statue Component instead, then the Table Component will remain where it is:

There are nodes to get and set a Component's Relative Location. You can also get a Component's World Location, as you can see in the following screenshot:

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

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