reckfellENGINE

ShapeCast3D

A 3D shape that sweeps a region of space to detect CollisionObject3Ds.

On this page
class ShapeCast3DReckfellSharpInherits Entity3D

A 3D shape that sweeps a region of space to detect CollisionObject3Ds.

Shape casting allows to detect collision objects by sweeping its ShapeCast3D.Shape along the cast direction determined by ShapeCast3D.TargetPosition. This is similar to RayCast3D, but it allows for sweeping a region of space, rather than just a straight line. ShapeCast3D can detect multiple collision objects. It is useful for things like wide laser beams or snapping a simple shape to a floor. Immediate collision overlaps can be done with the ShapeCast3D.TargetPosition set to Vector3(0, 0, 0) and by calling ShapeCast3D.ForceShapecastUpdate within the same physics frame. This helps to overcome some limitations of Area3D when used as an instantaneous detection area, as collision information isn't immediately available to it. Note: Shape casting is more computationally expensive than ray casting.

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

Constructors1

ShapeCast3DConstructor
# ShapeCast3D
C#
public ShapeCast3D();

Properties11

CollideWithAreasProperty
# CollideWithAreas
C#
public bool CollideWithAreas { get; set; }

If true, collisions with Area3Ds will be reported.

CollideWithBodiesProperty
# CollideWithBodies
C#
public bool CollideWithBodies { get; set; }

If true, collisions with PhysicsBody3Ds will be reported.

CollisionMaskProperty
# CollisionMask
C#
public uint CollisionMask { get; set; }

The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See Collision layers and masks in the documentation for more information.

CollisionResultProperty
# CollisionResult
C#
public Reckfell.Collections.Array CollisionResult { get; }

Returns the complete collision information from the collision sweep. The data returned is the same as in the PhysicsDirectSpaceState3D.GetRestInfo method.

DebugShapeCustomColorProperty
# DebugShapeCustomColor
C#
public Color DebugShapeCustomColor { get; set; }

The custom color to use to draw the shape in the editor and at run-time if Visible Collision Shapes is enabled in the Debug menu. This color will be highlighted at run-time if the ShapeCast3D is colliding with something. If set to Color(0.0, 0.0, 0.0) (by default), the color set in ProjectSettings.debug/shapes/collision/shape_color is used.

EnabledProperty
# Enabled
C#
public bool Enabled { get; set; }

If true, collisions will be reported.

ExcludeParentProperty
# ExcludeParent
C#
public bool ExcludeParent { get; set; }

If true, the parent node will be excluded from collision detection.

MarginProperty
# Margin
C#
public float Margin { get; set; }

The collision margin for the shape. A larger margin helps detecting collisions more consistently, at the cost of precision.

MaxResultsProperty
# MaxResults
C#
public int MaxResults { get; set; }

The number of intersections can be limited with this parameter, to reduce the processing time.

ShapeProperty
# Shape
C#
public Shape3D Shape { get; set; }

The shape to be used for collision queries.

TargetPositionProperty
# TargetPosition
C#
public Vector3 TargetPosition { get; set; }

The shape's destination point, relative to this node's Entity3D.Position.

Methods39

AddExceptionvoid
# AddException
C#
public void AddException(CollisionObject3D node);

Adds a collision exception so the shape does not report collisions with the specified node.

Parameters
NameTypeDefault
nodeCollisionObject3D—
AddExceptionRidvoid
# AddExceptionRid
C#
public void AddExceptionRid(Rid rid);

Adds a collision exception so the shape does not report collisions with the specified Rid.

Parameters
NameTypeDefault
ridRid—
ClearExceptionsvoid
# ClearExceptions
C#
public void ClearExceptions();

Removes all collision exceptions for this shape.

ForceShapecastUpdatevoid
# ForceShapecastUpdate
C#
public void ForceShapecastUpdate();

Updates the collision information for the shape immediately, without waiting for the next _physics_process call. Use this method, for example, when the shape or its parent has changed state. Note: Setting ShapeCast3D.Enabled to true is not required for this to work.

GetClosestCollisionSafeFractionfloat
# GetClosestCollisionSafeFraction
C#
public float GetClosestCollisionSafeFraction();

Returns the fraction from this cast's origin to its ShapeCast3D.TargetPosition of how far the shape can move without triggering a collision, as a value between 0.0 and 1.0.

Returns float
GetClosestCollisionUnsafeFractionfloat
# GetClosestCollisionUnsafeFraction
C#
public float GetClosestCollisionUnsafeFraction();

Returns the fraction from this cast's origin to its ShapeCast3D.TargetPosition of how far the shape must move to trigger a collision, as a value between 0.0 and 1.0. In ideal conditions this would be the same as ShapeCast3D.GetClosestCollisionSafeFraction, however shape casting is calculated in discrete steps, so the precise point of collision can occur between two calculated positions.

Returns float
GetColliderReckfellObject
# GetCollider
C#
public ReckfellObject GetCollider(int index);

Returns the collided ReckfellObject of one of the multiple collisions at index, or null if no object is intersecting the shape (i.e. ShapeCast3D.IsColliding returns false).

Parameters
NameTypeDefault
indexint—
Returns ReckfellObject
GetColliderRidRid
# GetColliderRid
C#
public Rid GetColliderRid(int index);

Returns the Rid of the collided object of one of the multiple collisions at index.

Parameters
NameTypeDefault
indexint—
Returns Rid
GetColliderShapeint
# GetColliderShape
C#
public int GetColliderShape(int index);

Returns the shape ID of the colliding shape of one of the multiple collisions at index, or 0 if no object is intersecting the shape (i.e. ShapeCast3D.IsColliding returns false).

Parameters
NameTypeDefault
indexint—
Returns int
GetCollisionCountint
# GetCollisionCount
C#
public int GetCollisionCount();

The number of collisions detected at the point of impact. Use this to iterate over multiple collisions as provided by ShapeCast3D.GetCollider, ShapeCast3D.GetColliderShape, ShapeCast3D.GetCollisionPoint, and ShapeCast3D.GetCollisionNormal methods.

Returns int
GetCollisionMaskuint
# GetCollisionMask
C#
public uint GetCollisionMask();
Returns uint
GetCollisionMaskValuebool
# GetCollisionMaskValue
C#
public bool GetCollisionMaskValue(int layerNumber);

Returns whether or not the specified layer of the ShapeCast3D.CollisionMask is enabled, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetCollisionNormalVector3
# GetCollisionNormal
C#
public Vector3 GetCollisionNormal(int index);

Returns the normal of one of the multiple collisions at index of the intersecting object.

Parameters
NameTypeDefault
indexint—
Returns Vector3
GetCollisionPointVector3
# GetCollisionPoint
C#
public Vector3 GetCollisionPoint(int index);

Returns the collision point of one of the multiple collisions at index where the shape intersects the colliding object. Note: This point is in the global coordinate system.

Parameters
NameTypeDefault
indexint—
Returns Vector3
GetCollisionResultReckfell.Collections.Array
# GetCollisionResult
C#
public Reckfell.Collections.Array GetCollisionResult();
Returns Reckfell.Collections.Array
GetDebugShapeCustomColorColor
# GetDebugShapeCustomColor
C#
public Color GetDebugShapeCustomColor();
Returns Color
GetExcludeParentBodybool
# GetExcludeParentBody
C#
public bool GetExcludeParentBody();
Returns bool
GetMarginfloat
# GetMargin
C#
public float GetMargin();
Returns float
GetMaxResultsint
# GetMaxResults
C#
public int GetMaxResults();
Returns int
GetShapeShape3D
# GetShape
C#
public Shape3D GetShape();
Returns Shape3D
GetTargetPositionVector3
# GetTargetPosition
C#
public Vector3 GetTargetPosition();
Returns Vector3
IsCollideWithAreasEnabledbool
# IsCollideWithAreasEnabled
C#
public bool IsCollideWithAreasEnabled();
Returns bool
IsCollideWithBodiesEnabledbool
# IsCollideWithBodiesEnabled
C#
public bool IsCollideWithBodiesEnabled();
Returns bool
IsCollidingbool
# IsColliding
C#
public bool IsColliding();

Returns whether any object is intersecting with the shape's vector (considering the vector length).

Returns bool
IsEnabledbool
# IsEnabled
C#
public bool IsEnabled();
Returns bool
RemoveExceptionvoid
# RemoveException
C#
public void RemoveException(CollisionObject3D node);

Removes a collision exception so the shape does report collisions with the specified node.

Parameters
NameTypeDefault
nodeCollisionObject3D—
RemoveExceptionRidvoid
# RemoveExceptionRid
C#
public void RemoveExceptionRid(Rid rid);

Removes a collision exception so the shape does report collisions with the specified Rid.

Parameters
NameTypeDefault
ridRid—
ResourceChangedvoid · Deprecated
# ResourceChanged
C#
public void ResourceChanged(Resource resource);

This method does nothing.

Parameters
NameTypeDefault
resourceResource—
SetCollideWithAreasvoid
# SetCollideWithAreas
C#
public void SetCollideWithAreas(bool enable);
Parameters
NameTypeDefault
enablebool—
SetCollideWithBodiesvoid
# SetCollideWithBodies
C#
public void SetCollideWithBodies(bool enable);
Parameters
NameTypeDefault
enablebool—
SetCollisionMaskvoid
# SetCollisionMask
C#
public void SetCollisionMask(uint mask);
Parameters
NameTypeDefault
maskuint—
SetCollisionMaskValuevoid
# SetCollisionMaskValue
C#
public void SetCollisionMaskValue(int layerNumber, bool value);

Based on value, enables or disables the specified layer in the ShapeCast3D.CollisionMask, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetDebugShapeCustomColorvoid
# SetDebugShapeCustomColor
C#
public void SetDebugShapeCustomColor(Color debugShapeCustomColor);
Parameters
NameTypeDefault
debugShapeCustomColorColor—
SetEnabledvoid
# SetEnabled
C#
public void SetEnabled(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetExcludeParentBodyvoid
# SetExcludeParentBody
C#
public void SetExcludeParentBody(bool mask);
Parameters
NameTypeDefault
maskbool—
SetMarginvoid
# SetMargin
C#
public void SetMargin(float margin);
Parameters
NameTypeDefault
marginfloat—
SetMaxResultsvoid
# SetMaxResults
C#
public void SetMaxResults(int maxResults);
Parameters
NameTypeDefault
maxResultsint—
SetShapevoid
# SetShape
C#
public void SetShape(Shape3D shape);
Parameters
NameTypeDefault
shapeShape3D—
SetTargetPositionvoid
# SetTargetPosition
C#
public void SetTargetPosition(Vector3 localPoint);
Parameters
NameTypeDefault
localPointVector3—
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.