Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AnimationMixer (2)
- AudioStreamPlayer
- CanvasItem (2)
- CanvasLayer (1)
- EditorFileSystem
- EditorPlugin (1)
- EditorResourcePreview
- HTTPRequest
- InstancePlaceholder
- MissingNode
- MultiplayerSpawner
- MultiplayerSynchronizer
- NavigationAgent2D
- NavigationAgent3D
- Node3D (31)
- ResourcePreloader
- ShaderGlobalsOverride
- StatusIndicator
- Timer
- Viewport (2)
- WorldEnvironment
- AudioListener3D
- AudioStreamPlayer3D
- BoneAttachment3D
- Camera3D (1)
- CollisionObject3D (2)
- CollisionPolygon3D
- CollisionShape3D
- GridMap
- ImporterMeshInstance3D
- Joint3D (5)
- LightmapProbe
- Marker3D
- NavigationLink3D
- NavigationObstacle3D
- NavigationRegion3D
- OpenXRCompositionLayer (3)
- OpenXRHand
- Path3D
- PathFollow3D
- RayCast3D
- RemoteTransform3D
- ShapeCast3D
- Skeleton3D
- SkeletonModifier3D (7)
- SpringArm3D
- SpringBoneCollision3D (3)
- VehicleWheel3D
- VisualInstance3D (13)
- XRFaceModifier3D
- XRNode3D (2)
- XROrigin3D
Table of contents
-
var collide_with_areas: bool = false -
var collide_with_bodies: bool = true -
var collision_mask: int = 1 -
var collision_result: Array = [] -
var debug_shape_custom_color: Color = Color(0, 0, 0, 1) -
var enabled: bool = true -
var exclude_parent: bool = true -
var margin: float = 0.0 -
var max_results: int = 32 -
var shape: Shape3D -
var target_position: Vector3 = Vector3(0, -1, 0) -
func add_exception(node: CollisionObject3D) -> void -
func add_exception_rid(rid: RID) -> void -
func clear_exceptions() -> void -
func force_shapecast_update() -> void -
const func get_closest_collision_safe_fraction() -> float -
const func get_closest_collision_unsafe_fraction() -> float -
const func get_collider(index: int) -> Object -
const func get_collider_rid(index: int) -> RID -
const func get_collider_shape(index: int) -> int -
const func get_collision_count() -> int -
const func get_collision_mask_value(layer_number: int) -> bool -
const func get_collision_normal(index: int) -> Vector3 -
const func get_collision_point(index: int) -> Vector3 -
const func is_colliding() -> bool -
func remove_exception(node: CollisionObject3D) -> void -
func remove_exception_rid(rid: RID) -> void -
func resource_changed(resource: Resource) -> void -
func set_collision_mask_value(value: bool) -> void
ShapeCast3D #
is_instantiable, Node3D, Node, core, not_builtin_classes
A 3D shape that sweeps a region of space to detect CollisionObject3Ds.
Shape casting allows to detect collision objects by sweeping its shape along the cast direction determined by target_position. 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 target_position set to Vector3(0, 0, 0) and by calling force_shapecast_update 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.
Members #
var collide_with_areas: bool = false#
If true, collisions with Area3Ds will be reported.
var collide_with_bodies: bool = true#
If true, collisions with PhysicsBody3Ds will be reported.
var collision_mask: int = 1#
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.
var collision_result: Array = []#
Returns the complete collision information from the collision sweep. The data returned is the same as in the PhysicsDirectSpaceState3D.get_rest_info method.
var debug_shape_custom_color: Color = Color(0, 0, 0, 1)#
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.
var enabled: bool = true#
If true, collisions will be reported.
var exclude_parent: bool = true#
If true, the parent node will be excluded from collision detection.
var margin: float = 0.0#
The collision margin for the shape. A larger margin helps detecting collisions more consistently, at the cost of precision.
var max_results: int = 32#
The number of intersections can be limited with this parameter, to reduce the processing time.
var shape: Shape3D#
The shape to be used for collision queries.
var target_position: Vector3 = Vector3(0, -1, 0)#
The shape's destination point, relative to this node's Node3D.position.
Methods #
func add_exception(node: CollisionObject3D) -> void#
Adds a collision exception so the shape does not report collisions with the specified node.
func add_exception_rid(rid: RID) -> void#
Adds a collision exception so the shape does not report collisions with the specified RID.
func clear_exceptions() -> void#
Removes all collision exceptions for this shape.
func force_shapecast_update() -> void#
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 enabled to true is not required for this to work.
const func get_closest_collision_safe_fraction() -> float#
Returns the fraction from this cast's origin to its target_position of how far the shape can move without triggering a collision, as a value between 0.0 and 1.0.
const func get_closest_collision_unsafe_fraction() -> float#
Returns the fraction from this cast's origin to its target_position 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 get_closest_collision_safe_fraction, however shape casting is calculated in discrete steps, so the precise point of collision can occur between two calculated positions.
const func get_collider(index: int) -> Object#
Returns the collided Object of one of the multiple collisions at index, or null if no object is intersecting the shape (i.e. is_colliding returns false).
const func get_collider_rid(index: int) -> RID#
Returns the RID of the collided object of one of the multiple collisions at index.
const func get_collider_shape(index: int) -> int#
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. is_colliding returns false).
const func get_collision_count() -> int#
The number of collisions detected at the point of impact. Use this to iterate over multiple collisions as provided by get_collider, get_collider_shape, get_collision_point, and get_collision_normal methods.
const func get_collision_mask_value(layer_number: int) -> bool#
Returns whether or not the specified layer of the collision_mask is enabled, given a layer_number between 1 and 32.
const func get_collision_normal(index: int) -> Vector3#
Returns the normal of one of the multiple collisions at index of the intersecting object.
const func get_collision_point(index: int) -> Vector3#
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.
const func is_colliding() -> bool#
Returns whether any object is intersecting with the shape's vector (considering the vector length).
func remove_exception(node: CollisionObject3D) -> void#
Removes a collision exception so the shape does report collisions with the specified node.
func remove_exception_rid(rid: RID) -> void#
Removes a collision exception so the shape does report collisions with the specified RID.
func resource_changed(resource: Resource) -> void#
This method does nothing.
func set_collision_mask_value(value: bool) -> void#
Based on value, enables or disables the specified layer in the collision_mask, given a layer_number between 1 and 32.