PhysicsServer is the server responsible for all 3D physics. It can create many kinds of physics objects, but does not insert them on the node tree.

Static variables

@:native("Singleton")staticread onlySINGLETON:Object

Static methods

@:native("AreaAddShape")staticareaAddShape(area:RID, shape:RID, ?transform:Transform, ?disabled:Bool):Void

Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.

Parameters:

transform

If the parameter is null, then the default value is Transform.Identity

@:native("AreaAttachObjectInstanceId")staticareaAttachObjectInstanceId(area:RID, id:UInt64):Void

Assigns the area to a descendant of godot.Object, so it can exist in the node tree.

@:native("AreaClearShapes")staticareaClearShapes(area:RID):Void

Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.

@:native("AreaCreate")staticareaCreate():RID

Creates an godot.Area.

@:native("AreaGetObjectInstanceId")staticareaGetObjectInstanceId(area:RID):UInt64

Gets the instance ID of the object the area is assigned to.

@:native("AreaGetParam")staticareaGetParam(area:RID, param:PhysicsServer_AreaParameter):Dynamic

Returns an area parameter value. A list of available parameters is on the godot.PhysicsServer_AreaParameter constants.

@:native("AreaGetShape")staticareaGetShape(area:RID, shapeIdx:Int):RID

Returns the godot.RID of the nth shape of an area.

@:native("AreaGetShapeCount")staticareaGetShapeCount(area:RID):Int

Returns the number of shapes assigned to an area.

@:native("AreaGetShapeTransform")staticareaGetShapeTransform(area:RID, shapeIdx:Int):Transform

Returns the transform matrix of a shape within an area.

@:native("AreaGetSpace")staticareaGetSpace(area:RID):RID

Returns the space assigned to the area.

@:native("AreaGetSpaceOverrideMode")staticareaGetSpaceOverrideMode(area:RID):PhysicsServer_AreaSpaceOverrideMode

Returns the space override mode for the area.

@:native("AreaGetTransform")staticareaGetTransform(area:RID):Transform

Returns the transform matrix for an area.

@:native("AreaIsRayPickable")staticareaIsRayPickable(area:RID):Bool

If true, area collides with rays.

@:native("AreaRemoveShape")staticareaRemoveShape(area:RID, shapeIdx:Int):Void

Removes a shape from an area. It does not delete the shape, so it can be reassigned later.

@:native("AreaSetAreaMonitorCallback")staticareaSetAreaMonitorCallback(area:RID, receiver:Object, method:String):Void

@:native("AreaSetCollisionLayer")staticareaSetCollisionLayer(area:RID, layer:UInt):Void

Assigns the area to one or many physics layers.

@:native("AreaSetCollisionMask")staticareaSetCollisionMask(area:RID, mask:UInt):Void

Sets which physics layers the area will monitor.

@:native("AreaSetMonitorCallback")staticareaSetMonitorCallback(area:RID, receiver:Object, method:String):Void

Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters:

1: godot.PhysicsServer_AreaBodyStatus.added or godot.PhysicsServer_AreaBodyStatus.removed, depending on whether the object entered or exited the area.

2: godot.RID of the object that entered/exited the area.

3: Instance ID of the object that entered/exited the area.

4: The shape index of the object that entered/exited the area.

5: The shape index of the area where the object entered/exited.

@:native("AreaSetMonitorable")staticareaSetMonitorable(area:RID, monitorable:Bool):Void

@:native("AreaSetParam")staticareaSetParam(area:RID, param:PhysicsServer_AreaParameter, value:Dynamic):Void

Sets the value for an area parameter. A list of available parameters is on the godot.PhysicsServer_AreaParameter constants.

@:native("AreaSetRayPickable")staticareaSetRayPickable(area:RID, enable:Bool):Void

Sets object pickable with rays.

@:native("AreaSetShape")staticareaSetShape(area:RID, shapeIdx:Int, shape:RID):Void

Substitutes a given area shape by another. The old shape is selected by its index, the new one by its godot.RID.

@:native("AreaSetShapeDisabled")staticareaSetShapeDisabled(area:RID, shapeIdx:Int, disabled:Bool):Void

@:native("AreaSetShapeTransform")staticareaSetShapeTransform(area:RID, shapeIdx:Int, transform:Transform):Void

Sets the transform matrix for an area shape.

@:native("AreaSetSpace")staticareaSetSpace(area:RID, space:RID):Void

Assigns a space to the area.

@:native("AreaSetSpaceOverrideMode")staticareaSetSpaceOverrideMode(area:RID, mode:PhysicsServer_AreaSpaceOverrideMode):Void

Sets the space override mode for the area. The modes are described in the godot.PhysicsServer_AreaSpaceOverrideMode constants.

@:native("AreaSetTransform")staticareaSetTransform(area:RID, transform:Transform):Void

Sets the transform matrix for an area.

@:native("BodyAddCentralForce")staticbodyAddCentralForce(body:RID, force:Vector3):Void

@:native("BodyAddCollisionException")staticbodyAddCollisionException(body:RID, exceptedBody:RID):Void

Adds a body to the list of bodies exempt from collisions.

@:native("BodyAddForce")staticbodyAddForce(body:RID, force:Vector3, position:Vector3):Void

@:native("BodyAddShape")staticbodyAddShape(body:RID, shape:RID, ?transform:Transform, ?disabled:Bool):Void

Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.

Parameters:

transform

If the parameter is null, then the default value is Transform.Identity

@:native("BodyAddTorque")staticbodyAddTorque(body:RID, torque:Vector3):Void

@:native("BodyApplyCentralImpulse")staticbodyApplyCentralImpulse(body:RID, impulse:Vector3):Void

@:native("BodyApplyImpulse")staticbodyApplyImpulse(body:RID, position:Vector3, impulse:Vector3):Void

Gives the body a push at a position in the direction of the impulse.

@:native("BodyApplyTorqueImpulse")staticbodyApplyTorqueImpulse(body:RID, impulse:Vector3):Void

Gives the body a push to rotate it.

@:native("BodyAttachObjectInstanceId")staticbodyAttachObjectInstanceId(body:RID, id:UInt):Void

Assigns the area to a descendant of godot.Object, so it can exist in the node tree.

@:native("BodyClearShapes")staticbodyClearShapes(body:RID):Void

Removes all shapes from a body.

@:native("BodyCreate")staticbodyCreate(?mode:PhysicsServer_BodyMode, ?initSleeping:Bool):RID

Creates a physics body. The first parameter can be any value from godot.PhysicsServer_BodyMode constants, for the type of body created. Additionally, the body can be created in sleeping state to save processing time.

@:native("BodyGetCollisionLayer")staticbodyGetCollisionLayer(body:RID):UInt

Returns the physics layer or layers a body belongs to.

@:native("BodyGetCollisionMask")staticbodyGetCollisionMask(body:RID):UInt

Returns the physics layer or layers a body can collide with.

@:native("BodyGetDirectState")staticbodyGetDirectState(body:RID):PhysicsDirectBodyState

Returns the godot.PhysicsDirectBodyState of the body. Returns null if the body is destroyed or removed from the physics space.

@:native("BodyGetKinematicSafeMargin")staticbodyGetKinematicSafeMargin(body:RID):Single

@:native("BodyGetMaxContactsReported")staticbodyGetMaxContactsReported(body:RID):Int

Returns the maximum contacts that can be reported. See godot.PhysicsServer.bodySetMaxContactsReported.

@:native("BodyGetMode")staticbodyGetMode(body:RID):PhysicsServer_BodyMode

Returns the body mode.

@:native("BodyGetObjectInstanceId")staticbodyGetObjectInstanceId(body:RID):UInt

Gets the instance ID of the object the area is assigned to.

@:native("BodyGetParam")staticbodyGetParam(body:RID, param:PhysicsServer_BodyParameter):Single

Returns the value of a body parameter. A list of available parameters is on the godot.PhysicsServer_BodyParameter constants.

@:native("BodyGetShape")staticbodyGetShape(body:RID, shapeIdx:Int):RID

Returns the godot.RID of the nth shape of a body.

@:native("BodyGetShapeCount")staticbodyGetShapeCount(body:RID):Int

Returns the number of shapes assigned to a body.

@:native("BodyGetShapeTransform")staticbodyGetShapeTransform(body:RID, shapeIdx:Int):Transform

Returns the transform matrix of a body shape.

@:native("BodyGetSpace")staticbodyGetSpace(body:RID):RID

Returns the godot.RID of the space assigned to a body.

@:native("BodyGetState")staticbodyGetState(body:RID, state:PhysicsServer_BodyState):Dynamic

Returns a body state.

@:native("BodyIsAxisLocked")staticbodyIsAxisLocked(body:RID, axis:PhysicsServer_BodyAxis):Bool

@:native("BodyIsContinuousCollisionDetectionEnabled")staticbodyIsContinuousCollisionDetectionEnabled(body:RID):Bool

If true, the continuous collision detection mode is enabled.

@:native("BodyIsOmittingForceIntegration")staticbodyIsOmittingForceIntegration(body:RID):Bool

Returns whether a body uses a callback function to calculate its own physics (see godot.PhysicsServer.bodySetForceIntegrationCallback).

@:native("BodyIsRayPickable")staticbodyIsRayPickable(body:RID):Bool

If true, the body can be detected by rays.

@:native("BodyRemoveCollisionException")staticbodyRemoveCollisionException(body:RID, exceptedBody:RID):Void

Removes a body from the list of bodies exempt from collisions.

Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.

@:native("BodyRemoveShape")staticbodyRemoveShape(body:RID, shapeIdx:Int):Void

Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.

@:native("BodySetAxisLock")staticbodySetAxisLock(body:RID, axis:PhysicsServer_BodyAxis, lock:Bool):Void

@:native("BodySetAxisVelocity")staticbodySetAxisVelocity(body:RID, axisVelocity:Vector3):Void

Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.

@:native("BodySetCollisionLayer")staticbodySetCollisionLayer(body:RID, layer:UInt):Void

Sets the physics layer or layers a body belongs to.

@:native("BodySetCollisionMask")staticbodySetCollisionMask(body:RID, mask:UInt):Void

Sets the physics layer or layers a body can collide with.

@:native("BodySetEnableContinuousCollisionDetection")staticbodySetEnableContinuousCollisionDetection(body:RID, enable:Bool):Void

If true, the continuous collision detection mode is enabled.

Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.

@:native("BodySetForceIntegrationCallback")staticbodySetForceIntegrationCallback(body:RID, receiver:Object, method:String, ?userdata:Dynamic):Void

Sets the function used to calculate physics for an object, if that object allows it (see godot.PhysicsServer.bodySetOmitForceIntegration).

@:native("BodySetKinematicSafeMargin")staticbodySetKinematicSafeMargin(body:RID, margin:Single):Void

@:native("BodySetMaxContactsReported")staticbodySetMaxContactsReported(body:RID, amount:Int):Void

Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.

@:native("BodySetMode")staticbodySetMode(body:RID, mode:PhysicsServer_BodyMode):Void

Sets the body mode, from one of the godot.PhysicsServer_BodyMode constants.

@:native("BodySetOmitForceIntegration")staticbodySetOmitForceIntegration(body:RID, enable:Bool):Void

Sets whether a body uses a callback function to calculate its own physics (see godot.PhysicsServer.bodySetForceIntegrationCallback).

@:native("BodySetParam")staticbodySetParam(body:RID, param:PhysicsServer_BodyParameter, value:Single):Void

Sets a body parameter. A list of available parameters is on the godot.PhysicsServer_BodyParameter constants.

@:native("BodySetRayPickable")staticbodySetRayPickable(body:RID, enable:Bool):Void

Sets the body pickable with rays if enabled is set.

@:native("BodySetShape")staticbodySetShape(body:RID, shapeIdx:Int, shape:RID):Void

Substitutes a given body shape by another. The old shape is selected by its index, the new one by its godot.RID.

@:native("BodySetShapeDisabled")staticbodySetShapeDisabled(body:RID, shapeIdx:Int, disabled:Bool):Void

@:native("BodySetShapeTransform")staticbodySetShapeTransform(body:RID, shapeIdx:Int, transform:Transform):Void

Sets the transform matrix for a body shape.

@:native("BodySetSpace")staticbodySetSpace(body:RID, space:RID):Void

Assigns a space to the body (see godot.PhysicsServer.spaceCreate).

@:native("BodySetState")staticbodySetState(body:RID, state:PhysicsServer_BodyState, value:Dynamic):Void

Sets a body state (see godot.PhysicsServer_BodyState constants).

@:native("BodyTestMotion")staticbodyTestMotion(body:RID, from:Transform, motion:Vector3, infiniteInertia:Bool, ?result:PhysicsTestMotionResult, ?excludeRaycastShapes:Bool, ?exclude:Array):Bool

Returns true if a collision would result from moving in the given direction from a given point in space. godot.PhysicsTestMotionResult can be passed to return additional information in.

Parameters:

exclude

If the parameter is null, then the default value is new Godot.Collections.Array { }

@:native("ConeTwistJointGetParam")staticconeTwistJointGetParam(joint:RID, param:PhysicsServer_ConeTwistJointParam):Single

Gets a cone_twist_joint parameter (see godot.PhysicsServer_ConeTwistJointParam constants).

@:native("ConeTwistJointSetParam")staticconeTwistJointSetParam(joint:RID, param:PhysicsServer_ConeTwistJointParam, value:Single):Void

Sets a cone_twist_joint parameter (see godot.PhysicsServer_ConeTwistJointParam constants).

@:native("FreeRid")staticfreeRid(rid:RID):Void

Destroys any of the objects created by PhysicsServer. If the godot.RID passed is not one of the objects that can be created by PhysicsServer, an error will be sent to the console.

@:native("Generic6dofJointGetFlag")staticgeneric6dofJointGetFlag(joint:RID, axis:Vector3_Axis, flag:PhysicsServer_G6DOFJointAxisFlag):Bool

Gets a generic_6_DOF_joint flag (see godot.PhysicsServer_G6DOFJointAxisFlag constants).

@:native("Generic6dofJointGetParam")staticgeneric6dofJointGetParam(joint:RID, axis:Vector3_Axis, param:PhysicsServer_G6DOFJointAxisParam):Single

Gets a generic_6_DOF_joint parameter (see godot.PhysicsServer_G6DOFJointAxisParam constants).

@:native("Generic6dofJointSetFlag")staticgeneric6dofJointSetFlag(joint:RID, axis:Vector3_Axis, flag:PhysicsServer_G6DOFJointAxisFlag, enable:Bool):Void

Sets a generic_6_DOF_joint flag (see godot.PhysicsServer_G6DOFJointAxisFlag constants).

@:native("Generic6dofJointSetParam")staticgeneric6dofJointSetParam(joint:RID, axis:Vector3_Axis, param:PhysicsServer_G6DOFJointAxisParam, value:Single):Void

Sets a generic_6_DOF_joint parameter (see godot.PhysicsServer_G6DOFJointAxisParam constants).

@:native("GetProcessInfo")staticgetProcessInfo(processInfo:PhysicsServer_ProcessInfo):Int

Returns information about the current state of the 3D physics engine. See godot.PhysicsServer_ProcessInfo for a list of available states. Only implemented for Godot Physics.

@:native("HingeJointGetFlag")statichingeJointGetFlag(joint:RID, flag:PhysicsServer_HingeJointFlag):Bool

Gets a hinge_joint flag (see godot.PhysicsServer_HingeJointFlag constants).

@:native("HingeJointGetParam")statichingeJointGetParam(joint:RID, param:PhysicsServer_HingeJointParam):Single

Gets a hinge_joint parameter (see godot.PhysicsServer_HingeJointParam).

@:native("HingeJointSetFlag")statichingeJointSetFlag(joint:RID, flag:PhysicsServer_HingeJointFlag, enabled:Bool):Void

Sets a hinge_joint flag (see godot.PhysicsServer_HingeJointFlag constants).

@:native("HingeJointSetParam")statichingeJointSetParam(joint:RID, param:PhysicsServer_HingeJointParam, value:Single):Void

Sets a hinge_joint parameter (see godot.PhysicsServer_HingeJointParam constants).

@:native("JointCreateConeTwist")staticjointCreateConeTwist(bodyA:RID, localRefA:Transform, bodyB:RID, localRefB:Transform):RID

@:native("JointCreateGeneric6dof")staticjointCreateGeneric6dof(bodyA:RID, localRefA:Transform, bodyB:RID, localRefB:Transform):RID

@:native("JointCreateHinge")staticjointCreateHinge(bodyA:RID, hingeA:Transform, bodyB:RID, hingeB:Transform):RID

Creates a godot.HingeJoint.

@:native("JointCreatePin")staticjointCreatePin(bodyA:RID, localA:Vector3, bodyB:RID, localB:Vector3):RID

Creates a godot.PinJoint.

@:native("JointCreateSlider")staticjointCreateSlider(bodyA:RID, localRefA:Transform, bodyB:RID, localRefB:Transform):RID

@:native("JointGetSolverPriority")staticjointGetSolverPriority(joint:RID):Int

Gets the priority value of the Joint.

@:native("JointGetType")staticjointGetType(joint:RID):PhysicsServer_JointType

Returns the type of the Joint.

@:native("JointSetSolverPriority")staticjointSetSolverPriority(joint:RID, priority:Int):Void

Sets the priority value of the Joint.

@:native("PinJointGetLocalA")staticpinJointGetLocalA(joint:RID):Vector3

Returns position of the joint in the local space of body a of the joint.

@:native("PinJointGetLocalB")staticpinJointGetLocalB(joint:RID):Vector3

Returns position of the joint in the local space of body b of the joint.

@:native("PinJointGetParam")staticpinJointGetParam(joint:RID, param:PhysicsServer_PinJointParam):Single

Gets a pin_joint parameter (see godot.PhysicsServer_PinJointParam constants).

@:native("PinJointSetLocalA")staticpinJointSetLocalA(joint:RID, localA:Vector3):Void

Sets position of the joint in the local space of body a of the joint.

@:native("PinJointSetLocalB")staticpinJointSetLocalB(joint:RID, localB:Vector3):Void

Sets position of the joint in the local space of body b of the joint.

@:native("PinJointSetParam")staticpinJointSetParam(joint:RID, param:PhysicsServer_PinJointParam, value:Single):Void

Sets a pin_joint parameter (see godot.PhysicsServer_PinJointParam constants).

@:native("SetActive")staticsetActive(active:Bool):Void

Activates or deactivates the 3D physics engine.

@:native("SetCollisionIterations")staticsetCollisionIterations(iterations:Int):Void

Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. The default value is 8.

Note: Only has an effect when using the GodotPhysics engine, not the default Bullet physics engine.

@:native("ShapeCreate")staticshapeCreate(type:PhysicsServer_ShapeType):RID

Creates a shape of a type from godot.PhysicsServer_ShapeType. Does not assign it to a body or an area. To do so, you must use godot.PhysicsServer.areaSetShape or godot.PhysicsServer.bodySetShape.

@:native("ShapeGetData")staticshapeGetData(shape:RID):Dynamic

Returns the shape data.

@:native("ShapeGetType")staticshapeGetType(shape:RID):PhysicsServer_ShapeType

Returns the type of shape (see godot.PhysicsServer_ShapeType constants).

@:native("ShapeSetData")staticshapeSetData(shape:RID, data:Dynamic):Void

Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created godot.PhysicsServer.shapeGetType.

@:native("SliderJointGetParam")staticsliderJointGetParam(joint:RID, param:PhysicsServer_SliderJointParam):Single

Gets a slider_joint parameter (see godot.PhysicsServer_SliderJointParam constants).

@:native("SliderJointSetParam")staticsliderJointSetParam(joint:RID, param:PhysicsServer_SliderJointParam, value:Single):Void

Gets a slider_joint parameter (see godot.PhysicsServer_SliderJointParam constants).

@:native("SpaceCreate")staticspaceCreate():RID

Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with godot.PhysicsServer.areaSetSpace, or to a body with godot.PhysicsServer.bodySetSpace.

@:native("SpaceGetDirectState")staticspaceGetDirectState(space:RID):PhysicsDirectSpaceState

Returns the state of a space, a godot.PhysicsDirectSpaceState. This object can be used to make collision/intersection queries.

@:native("SpaceGetParam")staticspaceGetParam(space:RID, param:PhysicsServer_SpaceParameter):Single

Returns the value of a space parameter.

@:native("SpaceIsActive")staticspaceIsActive(space:RID):Bool

Returns whether the space is active.

@:native("SpaceSetActive")staticspaceSetActive(space:RID, active:Bool):Void

Marks a space as active. It will not have an effect, unless it is assigned to an area or body.

@:native("SpaceSetParam")staticspaceSetParam(space:RID, param:PhysicsServer_SpaceParameter, value:Single):Void

Sets the value for a space parameter. A list of available parameters is on the godot.PhysicsServer_SpaceParameter constants.