reckfellENGINE

PhysicsBody3D

The base class for 3D physics bodies.

On this page
class PhysicsBody3DReckfellSharpInherits CollisionObject3D

PhysicsBody3D provides body operations and MoveAndCollide motion queries. Use CharacterBody for controlled characters, RigidBody for forces/impulses and StaticBody for walls.

MoveAndCollide tests distance displacement, returns a contact or null and supports testOnly without movement. Its result does not automatically slide or reflect. GetGravity provides the applicable field; applying it to character velocity remains your logic.

Working examples.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Properties6

AxisLockAngularXProperty
# AxisLockAngularX
C#
public bool AxisLockAngularX { get; set; }

Lock the body's rotation in the X axis.

AxisLockAngularYProperty
# AxisLockAngularY
C#
public bool AxisLockAngularY { get; set; }

Lock the body's rotation in the Y axis.

AxisLockAngularZProperty
# AxisLockAngularZ
C#
public bool AxisLockAngularZ { get; set; }

Lock the body's rotation in the Z axis.

AxisLockLinearXProperty
# AxisLockLinearX
C#
public bool AxisLockLinearX { get; set; }

Lock the body's linear movement in the X axis.

AxisLockLinearYProperty
# AxisLockLinearY
C#
public bool AxisLockLinearY { get; set; }

Lock the body's linear movement in the Y axis.

AxisLockLinearZProperty
# AxisLockLinearZ
C#
public bool AxisLockLinearZ { get; set; }

Lock the body's linear movement in the Z axis.

Methods8

AddCollisionExceptionWithvoid
# AddCollisionExceptionWith
C#
public void AddCollisionExceptionWith(Entity body);

Adds a body to the list of bodies that this body can't collide with.

Parameters
NameTypeDefault
bodyEntity—
GetAxisLockbool
# GetAxisLock
C#
public bool GetAxisLock(PhysicsServer3D.BodyAxis axis);

Returns true if the specified linear or rotational axis is locked.

Parameters
NameTypeDefault
axisPhysicsServer3D.BodyAxis—
Returns bool
GetCollisionExceptionsReckfell.Collections.Array<PhysicsBody3D>
# GetCollisionExceptions
C#
public Reckfell.Collections.Array<PhysicsBody3D> GetCollisionExceptions();

Returns an array of nodes that were added as collision exceptions for this body.

Returns Reckfell.Collections.Array<PhysicsBody3D>
GetGravityVector3
# GetGravity
C#
public Vector3 GetGravity();

Returns the gravity vector computed from all sources that can affect the body, including all gravity overrides from Area3D nodes and the global world gravity.

Returns Vector3
MoveAndCollideKinematicCollision3D
# MoveAndCollide
C#
public KinematicCollision3D MoveAndCollide(Vector3 motion, bool testOnly = false, float safeMargin = 0.001f, bool recoveryAsCollision = false, int maxCollisions = 1);

Tests displacement for this call, usually velocity × delta. Returns KinematicCollision or null. testOnly does not move the body; define subsequent sliding/reflection separately.

Parameters
NameTypeDefault
motionVector3—
testOnlyboolfalse
safeMarginfloat0.001f
recoveryAsCollisionboolfalse
maxCollisionsint1
Returns KinematicCollision3D
RemoveCollisionExceptionWithvoid
# RemoveCollisionExceptionWith
C#
public void RemoveCollisionExceptionWith(Entity body);

Removes a body from the list of bodies that this body can't collide with.

Parameters
NameTypeDefault
bodyEntity—
SetAxisLockvoid
# SetAxisLock
C#
public void SetAxisLock(PhysicsServer3D.BodyAxis axis, bool @lock);

Locks or unlocks the specified linear or rotational axis depending on the value of lock.

Parameters
NameTypeDefault
axisPhysicsServer3D.BodyAxis—
lockbool—
TestMovebool
# TestMove
C#
public bool TestMove(Transform3D from, Vector3 motion, KinematicCollision3D collision = null, float safeMargin = 0.001f, bool recoveryAsCollision = false, int maxCollisions = 1);

Checks for collisions without moving the body. In order to be frame rate independent in Entity._PhysicsProcess or Entity._Process, motion should be computed using delta. Virtually sets the node's position, scale and rotation to that of the given Transform3D, then tries to move the body along the vector motion. Returns true if a collision would stop the body from moving along the whole path. collision is an optional object of type KinematicCollision3D, which contains additional information about the collision when stopped, or when touching another body along the motion. safe_margin is the extra margin used for collision recovery (see CharacterBody3D.SafeMargin for more details). If recovery_as_collision is true, any depenetration from the recovery phase is also reported as a collision; this is useful for checking whether the body would touch any other bodies. max_collisions allows to retrieve more than one collision result.

Parameters
NameTypeDefault
fromTransform3D—
motionVector3—
collisionKinematicCollision3Dnull
safeMarginfloat0.001f
recoveryAsCollisionboolfalse
maxCollisionsint1
Returns bool
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.