Description
The X
property of the PhysicsLock
struct is a boolean value that determines whether the physics simulation for an object is locked along the X-axis. When set to true
, the object will not move or rotate along the X-axis, effectively constraining its movement in that direction.
Usage
Use the X
property to control the movement of a physics-enabled object along the X-axis. This is particularly useful in scenarios where you want to restrict an object's movement to specific axes, such as in a 2D game or when simulating certain mechanical constraints.
To lock the X-axis, set the property to true
. To allow movement along the X-axis, set it to false
.
Example
// Example of using the PhysicsLock struct to lock movement along the X-axis
PhysicsLock lockSettings = new PhysicsLock();
lockSettings.X = true; // Lock movement along the X-axis
lockSettings.Y = false; // Allow movement along the Y-axis
lockSettings.Z = false; // Allow movement along the Z-axis
// Apply the lock settings to a physics-enabled object
GameObject myObject = new GameObject();
myObject.PhysicsLock = lockSettings;