GSmGpE6CwX2y9JjB25B8
We use cookies on this site to enhance your user experience

Positioning Objects

Positioning Objects

Aug 29 2019, 9:14 AM PST 5 min

Physical objects in a Roblox game can be positioned in various ways, depending on your design goals.

Object Position

The global position of an object is determined by its three Position properties: X, Y, and Z. This position is based on the center of the object.

To position an object in Roblox Studio, use the Move tool located in the Home or Model tabs. Alternatively, you can set the Position properties directly in the Properties window.

Properties - Part "Part"
Data
ClassName Part
Name Part
Orientation
0, 0, 0
Parent Workspace
Position
-20, 4, 54
     X -20
     Y 4
     Z 54

Object Orientation

The orientation (rotation) of an object is determined by its three Orientation properties. Like position, this orientation is based on the center of the object.

To change the orientation of an object in Studio, use the Rotate tool located in the Home or Model tabs. Alternatively, you can set the Orientation properties (in degrees) directly in the Properties window.

Properties - Part "Part"
Data
ClassName Part
Name Part
Orientation
0, 0, 0
     X 0
     Y 0
     Z 0
Parent Workspace
Position
-20, 4, 54

Coordinate Frames

A Coordinate Frame (datatype/CFrame|CFrame) is a powerful data type which contains global X, Y, and Z coordinates and rotation data for each axis. In addition, datatype/CFrame|CFrames contain helpful functions for working with objects in the 3D space, for instance:

  • Changing an object’s position or orientation relative to its current position/orientation.
  • Facing a specific surface of a part toward a point in the world, for example pointing the tip of a rocket toward its target.

See /articles/Understanding CFrame|Understanding CFrames for details and practical examples.

Anchoring Objects

By default, all physical objects will obey physical rules — they will fall under simulated gravity, slide down slopes, etc. To lock an object in place and prevent it from moving, even under heavy collisions or other extreme forces, toggle on its BasePart/Anchored|Anchored property in the Home/Model tabs or within the Properties window.

Properties - Part "Part"
Behavior
Anchored
Archivable
CanCollide
CollisionGroupId 0
Locked

Positioning Models

When positioning a Model which is a group of BasePart|BaseParts, its bounding box defines its center. For a model like this pine tree, however, a more logical positioning point is the base of its trunk.

When dealing with a model, you should assign it a Model/PrimaryPart|PrimaryPart which will be used as a basis for positioning (this can be done directly within Studio or via a script). A model’s Model/PrimaryPart|PrimaryPart is indicated by the grey outline as seen on the tree trunk above.

Properties - Model "Pine Tree"
Data
ClassName Model
Name Pine Tree
Parent Workspace
PrimaryPart TrunkBase
Behavior

Once a Model/PrimaryPart|PrimaryPart is defined, you can call the model’s Model/SetPrimaryPartCFrame|SetPrimaryPartCFrame() method inside a script, providing a valid datatype/CFrame|CFrame at which to position and orient it.

Tags:
  • position
  • orientation
  • placement