From f979d5977ac77bdc47c1d7865a221a46991e30ab Mon Sep 17 00:00:00 2001 From: "Andrii Doroshenko (Xrayez)" Date: Tue, 9 Nov 2021 15:47:29 +0200 Subject: Add `ShapeCast2D` node --- doc/classes/ShapeCast2D.xml | 182 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 doc/classes/ShapeCast2D.xml (limited to 'doc/classes') diff --git a/doc/classes/ShapeCast2D.xml b/doc/classes/ShapeCast2D.xml new file mode 100644 index 0000000000..e202d058b1 --- /dev/null +++ b/doc/classes/ShapeCast2D.xml @@ -0,0 +1,182 @@ + + + + Node for physics collision sweep and immediate overlap queries. Similar to the [RayCast2D] node. + + + Shape casting allows to detect collision objects by sweeping the [member shape] along the cast direction determined by [member target_position] (useful for things like beam weapons). + Immediate collision overlaps can be done with the [member target_position] set to [code]Vector2(0, 0)[/code] and by calling [method force_shapecast_update] within the same [b]physics_frame[/b]. This also helps to overcome some limitations of [Area2D] when used as a continuous detection area, often requiring waiting a couple of frames before collision information is available to [Area2D] nodes, and when using the signals creates unnecessary complexity. + The node can detect multiple collision objects, but usually the first detected collision + [b]Note:[/b] shape casting is more computationally expensive compared to ray casting. + + + + + + + + + Adds a collision exception so the shape does not report collisions with the specified node. + + + + + + + Adds a collision exception so the shape does not report collisions with the specified [RID]. + + + + + + Removes all collision exceptions for this shape. + + + + + + Updates the collision information for the shape. Use this method to update the collision information immediately instead of waiting for the next [code]_physics_process[/code] call, for example if the shape or its parent has changed state. + [b]Note:[/b] [code]enabled == true[/code] is not required for this to work. + + + + + + Returns the first object that the shape intersects, or [code]null[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]). + + + + + + Returns the shape ID of the first object that the shape intersects, or [code]0[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]). + + + + + + Returns the normal of the closest intersecting object's shape at the collision point. + + + + + + Returns the collision point at which the shape intersects the closest object. + [b]Note:[/b] this point is in the [b]global[/b] coordinate system. + + + + + + The fraction of the motion (between 0 and 1) of how far the shape can move without triggering a collision. The motion is determined by [member target_position]. + + + + + + The fraction of the motion (between 0 and 1) when the shape triggers a collision. The motion is determined by [member target_position]. + + + + + + + Returns the [Object] of one of the multiple collisions at [code]index[/code], or [code]null[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]). + + + + + + + Returns the shape ID of one of the multiple collisions at [code]index[/code] that the shape intersects, or [code]0[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]). + + + + + + The number of collisions detected at the point of impact. Use this to iterate over multiple collisions as provided by [method get_collider], [method get_collider_shape], [method get_collision_point], and [method get_collision_normal] methods. + + + + + + + Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [code]layer_number[/code] between 1 and 32. + + + + + + + Returns the normal containing one of the multiple collisions at [code]index[/code] of the intersecting object. + + + + + + + Returns the collision point containing one of the multiple collisions at [code]index[/code] at which the shape intersects the object. + [b]Note:[/b] this point is in the [b]global[/b] coordinate system. + + + + + + Returns whether any object is intersecting with the shape's vector (considering the vector length). + + + + + + + Removes a collision exception so the shape does report collisions with the specified node. + + + + + + + Removes a collision exception so the shape does report collisions with the specified [RID]. + + + + + + + + Based on [code]value[/code], enables or disables the specified layer in the [member collision_mask], given a [code]layer_number[/code] between 1 and 32. + + + + + + If [code]true[/code], collision with [Area2D]s will be reported. + + + If [code]true[/code], collision with [PhysicsBody2D]s will be reported. + + + The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. + + + A complete collision information. The data returned is the same as in the [method PhysicsDirectSpaceState2D.get_rest_info] method. + + + If [code]true[/code], collisions will be reported. + + + If [code]true[/code], the parent node will be excluded from collision detection. + + + The collision margin for the shape. A larger margin helps detecting collisions more consistently, at the cost of precision. + + + The number of intersections can be limited with this parameter, to reduce the processing time. + + + Any [Shape2D] derived shape used for collision queries. + + + The shape's destination point, relative to this node's [code]position[/code]. + + + -- cgit v1.2.3 From 6a673509106bfe7e9c7978d392d8cde3c1b65dc8 Mon Sep 17 00:00:00 2001 From: "Andrii Doroshenko (Xrayez)" Date: Fri, 12 Nov 2021 21:30:35 +0200 Subject: Remove `get_closest_*` methods from `ShapeCast2D` The physics API cannot provide needed functionality to ensure the correct behavior, which might lead to confusion (see `rest_info()`). However `get_closest_collision_safe/unsafe_fraction()` methods are not removed, because they return correct result from `cast_motion()`. --- doc/classes/ShapeCast2D.xml | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'doc/classes') diff --git a/doc/classes/ShapeCast2D.xml b/doc/classes/ShapeCast2D.xml index e202d058b1..74ebafe069 100644 --- a/doc/classes/ShapeCast2D.xml +++ b/doc/classes/ShapeCast2D.xml @@ -39,31 +39,6 @@ [b]Note:[/b] [code]enabled == true[/code] is not required for this to work. - - - - Returns the first object that the shape intersects, or [code]null[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]). - - - - - - Returns the shape ID of the first object that the shape intersects, or [code]0[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]). - - - - - - Returns the normal of the closest intersecting object's shape at the collision point. - - - - - - Returns the collision point at which the shape intersects the closest object. - [b]Note:[/b] this point is in the [b]global[/b] coordinate system. - - -- cgit v1.2.3