What is the difference between Relative and World location?
In Unreal Engine, there are two types of location systems that are commonly used: relative location and world location. Or relative and world transform.
Although both of these location systems can be used to position objects in a level, they differ in important ways. In this blog post, we will explore the difference between relative and world location in Unreal Engine, and how they are used in game development.
Whether you are a beginner or an experienced game developer, understanding these location systems is essential for creating games. If you want to learn more, read our Transform for Beginners Guide.
World Location or Absolute Location
World location in Unreal Engine refers to the absolute location of an object or actor in the game world or map. In other words, it refers to an object’s exact coordinates within the level.
An absolute location of “0,0,0” will always be the center of your level.
It’s a way of measuring the position, location, and scale of an object based on its relationship to the entire game world. So, an object’s position in the world is not dependent on its relationship to another object or character, but rather its position in the game world as a whole.
When we talk about relative location, we mean the location of something compared to the thing it belongs to, like a parent object or character. So, the relative location is always measured based on its relationship to its parent.
For example, if you have a character with a weapon, the weapon’s position would be relative to the character’s position. This means that if the character moves, the weapon’s position will also change accordingly.
Real Example in Unreal Engine:
To help you understand better, let’s take a look at the location of a cube in Unreal Engine.
This cube is a static mesh and has the same relative and world location because it’s placed directly on the level, without any other components or actors affecting its position. Root Components will always have the same absolute and relative location.
If we select the sphere that’s inside the cube, we’ll notice that its relative and absolute location values are different from the cube’s.
The sphere’s relative location is the same as its parent (the cube) except for a 20-unit increase on the Z axis. This is why the sphere is sticking out of the cube in the image below. But the X and Y axis maintain the same values.
Now, let’s check the sphere’s absolute location. We’ll notice that it’s the same as its parent (the cube) except for the 20-unit increase on the Z axis. Changing the value from 160 to 180 units.
Set Relative and World Transform Nodes in Unreal Engine
So, let’s take a look at 10 Blueprint nodes that are based on relative and world transforms.
Set Relative Transform Nodes in Unreal Engine
- Set Relative Location: Set the location of the component relative to its parent.
- Set Relative Rotation: Set the rotation of the component relative to its parent.
- Set Relative Location and Rotation: Set the location and rotation of the component relative to its parent.
- Set Relative Scale 3D: Set the non-uniform of the component relative to its parent.
- Set Relative Transform: Set the transform of the component relative to its parent. You can right click on “New Transform” and select “Split Struct Pin” to access the location, rotation and scale values separately.
Set World Transform Nodes in Unreal Engine
- Set World Location: Put this component at the specified location in world space. Updates relative location to achieve the final world location.
- Set World Rotation: Put this component at the specified rotation in world space. Updates relative rotation to achieve the final world location.
- Set World Location and Rotation: Set the relative location and rotation of the component to put it at the supplied pose in world space.
- Set World Scale 3D: Set the relative scale of the component to put it at the supplied scale in world space.
- Set World Transform: Set the transform of the component in world space.
A helpful thing to know in Unreal Engine is that the pins for location are always yellow, the pins for rotation are light purple, and the pins for transform are orange. Remembering this can make it easier to work with the engine when you’re moving and positioning objects or characters in your game.
You can use the Gizmo (1), the Transform Tool (2), and the Coordinate System (3) as a reference to determine which direction you should move the player.
What is Sweep and Teleport in Unreal Engine?
Sweep is used for limiting movement. When we move an object using the sweep feature, it checks for any collisions in its path and stops moving if it encounters a blocking obstacle. The sweep function only applies to the main component of the object, and not any attached parts. However, if collision detection is turned off, the sweep feature won’t work.
Let’s say you want to stop a player from walking through walls. Enabling sweep, will stop the player’s movement at the first blocking volume it hits.
Teleport moves objects to the new position instantly, without affecting their velocity. If this option is enabled, the physics velocity for this object remain unchanged. If it’s disabled, physics velocity is updated based on the new position.
Now you know about relative and world transform in Unreal Engine.
What is the difference between ADD and SET World or Local Transform?
The Add World Transform and Set World Transform nodes in Unreal Engine are both Blueprint nodes that enable you to change the transform (position, rotation, and scale) of a specific Actor in the game world. There are, however, some significant distinctions between the two nodes.
Add World Transform is a relative action, but Set World Transform is an absolute operation. Please read this blog article to learn more.
Hope This Helps! Keep On Creating!