PhysicsWorldclass

A world in which physics objects exist. You can create your own world but you really don't need to. A world for the map is created clientside and serverside automatically.

objectPhysicsWorld
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.PhysicsWorld

Constructors1

Showing 1 constructors

public PhysicsWorld()PUBLICCONSTRUCTOR

Create a new physics world. You should only do this if you want to simulate an extra world for some reason.

Methods11

Showing 11 methods

public void DebugDraw()PUBLIC

Updates all the SceneObjects in the `Sandbox.PhysicsWorld.DebugSceneWorld`, call once per tick or frame.

Returns:void

public void Delete()PUBLIC

Delete this world and all objects inside. Will throw an exception if you try to delete a world that you didn't manually create.

Returns:void

public Sandbox.Physics.CollisionRules.Result GetCollisionRule(string left, string right)PUBLIC

Gets the specific collision rule for a pair of tags.

ParameterTypeDescription
leftstring
rightstring
Returns:Result

public void SetCollisionRules(Sandbox.Physics.CollisionRules rules)PUBLICOBSOLETE

Used internally to set collision rules from gamemode's project settings. You shouldn't need to call this yourself.

Obsolete: Use CollisionRules Property

ParameterTypeDescription
rulesCollisionRules
Returns:void

Properties14

Showing 14 properties

public float Sandbox.PhysicsWorld.AirDensity { get; set; }PUBLICGETSET

Air density of this physics world, for things like air drag.

Returns:float

public System.Collections.Generic.IEnumerable`1<Sandbox.PhysicsBody> Sandbox.PhysicsWorld.Bodies { get; set; }PUBLICGETSET

All bodies in the world

Returns:IEnumerable<PhysicsBody>

public Sandbox.PhysicsGroup Sandbox.PhysicsWorld.Group { get; set; }PUBLICGETSET

The physics group of this physics world. A physics world will contain only 1 body.

Returns:PhysicsGroup

public int Sandbox.PhysicsWorld.PositionIterations { get; set; }PUBLICGETSETOBSOLETE

Obsolete: This API member is obsolete.

Returns:int

public bool Sandbox.PhysicsWorld.SleepingEnabled { get; set; }PUBLICGETSET

If true then bodies will be able to sleep after a period of inactivity

Returns:bool

public int Sandbox.PhysicsWorld.SubSteps { get; set; }PUBLICGETSET

If you're seeing objects go through other objects or you have a low tickrate, you might want to increase the number of physics substeps. This breaks physics steps down into this many substeps. The default is 1 and works pretty good. Be aware that the number of physics ticks per second is going to be tickrate * substeps. So if you're ticking at 90 and you have SubSteps set to 1000 then you're going to do 90,000 steps per second. So be careful here.

Returns:int

public float Sandbox.PhysicsWorld.TimeScale { get; set; }PUBLICGETSETOBSOLETE

Obsolete: This API member is obsolete.

Returns:float

public int Sandbox.PhysicsWorld.VelocityIterations { get; set; }PUBLICGETSETOBSOLETE

Obsolete: This API member is obsolete.

Returns:int

On this page

Constructorspublic PhysicsWorld()Methodspublic System.Void DebugDraw()public System.Void Delete()public Sandbox.Physics.CollisionRules.Result GetCollisionRule(System.String left, System.String right)public Sandbox.PhysicsTraceResult RunTrace(Sandbox.PhysicsTraceBuilder trace)public Sandbox.PhysicsTraceResult[] RunTraceAll(Sandbox.PhysicsTraceBuilder trace)public System.Void SetCollisionRules(Sandbox.Physics.CollisionRules rules)public Sandbox.PhysicsGroup SetupPhysicsFromModel(Sandbox.Model model, Sandbox.PhysicsMotionType motionType)public Sandbox.PhysicsGroup SetupPhysicsFromModel(Sandbox.Model model, Transform transform, Sandbox.PhysicsMotionType motionType)public System.Void Step(System.Double worldTime, System.Single delta, System.Int32 subSteps)public System.Void Step(System.Single delta, System.Int32 subSteps)public System.Void Step(System.Single delta)Propertiespublic System.Single Sandbox.PhysicsWorld.AirDensity { get; set; }public System.Collections.Generic.IEnumerable`1<Sandbox.PhysicsBody> Sandbox.PhysicsWorld.Bodies { get; set; }public Sandbox.PhysicsBody Sandbox.PhysicsWorld.Body { get; set; }public Sandbox.Physics.CollisionRules Sandbox.PhysicsWorld.CollisionRules { get; set; }public Sandbox.SceneWorld Sandbox.PhysicsWorld.DebugSceneWorld { get; set; }public Vector3 Sandbox.PhysicsWorld.Gravity { get; set; }public Sandbox.PhysicsGroup Sandbox.PhysicsWorld.Group { get; set; }public System.Int32 Sandbox.PhysicsWorld.PositionIterations { get; set; }public Sandbox.PhysicsSimulationMode Sandbox.PhysicsWorld.SimulationMode { get; set; }public System.Boolean Sandbox.PhysicsWorld.SleepingEnabled { get; set; }public System.Int32 Sandbox.PhysicsWorld.SubSteps { get; set; }public System.Single Sandbox.PhysicsWorld.TimeScale { get; set; }public Sandbox.PhysicsTraceBuilder Sandbox.PhysicsWorld.Trace { get; set; }public System.Int32 Sandbox.PhysicsWorld.VelocityIterations { get; set; }Metadata