Vector3 Gravity { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Gravity property of the PhysicsWorld class provides access to the current gravity vector applied within the physics world. This property is essential for simulating realistic physics interactions, as it determines the force exerted on objects due to gravity.

Usage

To access or modify the gravity in a PhysicsWorld, use the Gravity property. This property is of type Vector3, allowing you to specify the direction and magnitude of the gravitational force.

Example usage:

PhysicsWorld world = new PhysicsWorld();
Vector3 currentGravity = world.Gravity;
world.Gravity = new Vector3(0, 0, -9.81f); // Set gravity to Earth's gravity

Example

PhysicsWorld world = new PhysicsWorld();

// Access the current gravity
Vector3 currentGravity = world.Gravity;

// Set a new gravity vector
world.Gravity = new Vector3(0, 0, -9.81f); // Simulate Earth's gravity