Api Sandbox PhysicsWorld
class

PhysicsWorld

public sealed class PhysicsWorld

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.

Constructors

PhysicsWorld()

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

Properties

Name Type Description
Bodies IEnumerable<PhysicsBody> All bodies in the world
CollisionRules CollisionRules Set or retrieve the collision rules for this PhysicsWorld.
Gravity Vector3 Access the world's current gravity.
AirDensity Single Air density of this physics world, for things like air drag.
Body PhysicsBody The body of this physics world.
Group PhysicsGroup The physics group of this physics world. A physics world will contain only 1 body.
SleepingEnabled Boolean If true then bodies will be able to sleep after a period of inactivity
SimulationMode PhysicsSimulationMode Physics simulation mode. See PhysicsSimulationMode for explanation of each mode.
PositionIterations Int32
VelocityIterations Int32
SubSteps Int32 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.
TimeScale Single
Trace PhysicsTraceBuilder Raytrace against this world
DebugSceneWorld SceneWorld A SceneWorld where debug SceneObjects exist.

Methods

PhysicsGroup SetupPhysicsFromModel(Model model, PhysicsMotionType motionType)

Temp function for creating model physics until entity system handles it

PhysicsGroup SetupPhysicsFromModel(Model model, Transform transform, PhysicsMotionType motionType)

Temp function for creating model physics until entity system handles it

Void Delete()

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

Void Step(Single delta)

Step simulation of this physics world. You can only do this on physics worlds that you manually create.

Void Step(Single delta, Int32 subSteps)

Step simulation of this physics world. You can only do this on physics worlds that you manually create.

Void Step(Double worldTime, Single delta, Int32 subSteps)

Step simulation of this physics world. You can only do this on physics worlds that you manually create.

Void SetCollisionRules(CollisionRules rules)

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

Result GetCollisionRule(String left, String right)

Gets the specific collision rule for a pair of tags.

PhysicsTraceResult RunTrace(PhysicsTraceBuilder trace)

Like calling PhysicsTraceBuilder.Run, except will re-target this world if it's not already the target

PhysicsTraceResult[] RunTraceAll(PhysicsTraceBuilder trace)

Like calling PhysicsTraceBuilder.RunAll, except will re-target this world if it's not already the target

Void DebugDraw()

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

Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.PhysicsWorld