Documentation
¶
Overview ¶
Package ShapeCast2D provides methods for working with ShapeCast2D object instances.
Index ¶
- type Advanced
- type Any
- type Instance
- func (self Instance) AddException(node [1]gdclass.CollisionObject2D)
- func (self Instance) AddExceptionRid(rid RID.Body2D)
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Node2D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsShapeCast2D() Instance
- func (self Instance) ClearExceptions()
- func (self Instance) CollideWithAreas() bool
- func (self Instance) CollideWithBodies() bool
- func (self Instance) CollisionMask() int
- func (self Instance) Enabled() bool
- func (self Instance) ExcludeParent() bool
- func (self Instance) ForceShapecastUpdate()
- func (self Instance) GetClosestCollisionSafeFraction() Float.X
- func (self Instance) GetClosestCollisionUnsafeFraction() Float.X
- func (self Instance) GetCollider(index int) Object.Instance
- func (self Instance) GetColliderRid(index int) RID.Body2D
- func (self Instance) GetColliderShape(index int) int
- func (self Instance) GetCollisionCount() int
- func (self Instance) GetCollisionMaskValue(layer_number int) bool
- func (self Instance) GetCollisionNormal(index int) Vector2.XY
- func (self Instance) GetCollisionPoint(index int) Vector2.XY
- func (self Instance) IsColliding() bool
- func (self Instance) Margin() Float.X
- func (self Instance) MaxResults() int
- func (self Instance) RemoveException(node [1]gdclass.CollisionObject2D)
- func (self Instance) RemoveExceptionRid(rid RID.Body2D)
- func (self Instance) SetCollideWithAreas(value bool)
- func (self Instance) SetCollideWithBodies(value bool)
- func (self Instance) SetCollisionMask(value int)
- func (self Instance) SetCollisionMaskValue(layer_number int, value bool)
- func (self Instance) SetEnabled(value bool)
- func (self Instance) SetExcludeParent(value bool)
- func (self Instance) SetMargin(value Float.X)
- func (self Instance) SetMaxResults(value int)
- func (self Instance) SetShape(value [1]gdclass.Shape2D)
- func (self Instance) SetTargetPosition(value Vector2.XY)
- func (self Instance) Shape() [1]gdclass.Shape2D
- func (self Instance) TargetPosition() Vector2.XY
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Instance ¶
type Instance [1]gdclass.ShapeCast2D
Shape casting allows to detect collision objects by sweeping its [member shape] along the cast direction determined by [member target_position]. This is similar to [RayCast2D], but it allows for sweeping a region of space, rather than just a straight line. [ShapeCast2D] 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 [member target_position] set to [code]Vector2(0, 0)[/code] and by calling [method force_shapecast_update] within the same physics frame. This helps to overcome some limitations of [Area2D] when used as an instantaneous detection area, as collision information isn't immediately available to it. [b]Note:[/b] Shape casting is more computationally expensive than ray casting.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AddException ¶
func (self Instance) AddException(node [1]gdclass.CollisionObject2D)
Adds a collision exception so the shape does not report collisions with the specified [CollisionObject2D] node.
func (Instance) AddExceptionRid ¶
Adds a collision exception so the shape does not report collisions with the specified [RID].
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsShapeCast2D ¶
func (Instance) ClearExceptions ¶
func (self Instance) ClearExceptions()
Removes all collision exceptions for this shape.
func (Instance) CollideWithAreas ¶
func (Instance) CollideWithBodies ¶
func (Instance) CollisionMask ¶
func (Instance) ExcludeParent ¶
func (Instance) ForceShapecastUpdate ¶
func (self Instance) ForceShapecastUpdate()
Updates the collision information for the shape immediately, without waiting for the next [code]_physics_process[/code] call. Use this method, for example, when the shape or its parent has changed state. [b]Note:[/b] [code]enabled == true[/code] is not required for this to work.
func (Instance) GetClosestCollisionSafeFraction ¶
The fraction from the [ShapeCast2D]'s origin to its [member target_position] (between 0 and 1) of how far the shape can move without triggering a collision.
func (Instance) GetClosestCollisionUnsafeFraction ¶
The fraction from the [ShapeCast2D]'s origin to its [member target_position] (between 0 and 1) of how far the shape must move to trigger a collision. In ideal conditions this would be the same as [method 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.
func (Instance) GetCollider ¶
Returns the collided [Object] of one of the multiple collisions at [param index], or [code]null[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]).
func (Instance) GetColliderRid ¶
Returns the [RID] of the collided object of one of the multiple collisions at [param index].
func (Instance) GetColliderShape ¶
Returns the shape ID of the colliding shape of one of the multiple collisions at [param index], or [code]0[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]).
func (Instance) GetCollisionCount ¶
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.
func (Instance) GetCollisionMaskValue ¶
Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
func (Instance) GetCollisionNormal ¶
Returns the normal of one of the multiple collisions at [param index] of the intersecting object.
func (Instance) GetCollisionPoint ¶
Returns the collision point of one of the multiple collisions at [param index] where the shape intersects the colliding object. [b]Note:[/b] this point is in the [b]global[/b] coordinate system.
func (Instance) IsColliding ¶
Returns whether any object is intersecting with the shape's vector (considering the vector length).
func (Instance) MaxResults ¶
func (Instance) RemoveException ¶
func (self Instance) RemoveException(node [1]gdclass.CollisionObject2D)
Removes a collision exception so the shape does report collisions with the specified [CollisionObject2D] node.
func (Instance) RemoveExceptionRid ¶
Removes a collision exception so the shape does report collisions with the specified [RID].
func (Instance) SetCollideWithAreas ¶
func (Instance) SetCollideWithBodies ¶
func (Instance) SetCollisionMask ¶
func (Instance) SetCollisionMaskValue ¶
Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.