ShapeCast2D

package
v0.0.0-...-546f9d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package ShapeCast2D provides methods for working with ShapeCast2D object instances.

Index

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 Any

type Any interface {
	gd.IsClass
	AsShapeCast2D() Instance
}

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 New

func New() Instance

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

func (self Instance) AddExceptionRid(rid RID.Body2D)

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) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Node2D.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsShapeCast2D

func (self Instance) AsShapeCast2D() Instance

func (Instance) ClearExceptions

func (self Instance) ClearExceptions()

Removes all collision exceptions for this shape.

func (Instance) CollideWithAreas

func (self Instance) CollideWithAreas() bool

func (Instance) CollideWithBodies

func (self Instance) CollideWithBodies() bool

func (Instance) CollisionMask

func (self Instance) CollisionMask() int

func (Instance) Enabled

func (self Instance) Enabled() bool

func (Instance) ExcludeParent

func (self Instance) ExcludeParent() bool

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

func (self Instance) GetClosestCollisionSafeFraction() Float.X

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

func (self Instance) GetClosestCollisionUnsafeFraction() Float.X

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

func (self Instance) GetCollider(index int) Object.Instance

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

func (self Instance) GetColliderRid(index int) RID.Body2D

Returns the [RID] of the collided object of one of the multiple collisions at [param index].

func (Instance) GetColliderShape

func (self Instance) GetColliderShape(index int) int

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

func (self Instance) GetCollisionCount() int

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

func (self Instance) GetCollisionMaskValue(layer_number int) bool

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

func (self Instance) GetCollisionNormal(index int) Vector2.XY

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

func (Instance) GetCollisionPoint

func (self Instance) GetCollisionPoint(index int) Vector2.XY

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

func (self Instance) IsColliding() bool

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

func (Instance) Margin

func (self Instance) Margin() Float.X

func (Instance) MaxResults

func (self Instance) MaxResults() int

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

func (self Instance) RemoveExceptionRid(rid RID.Body2D)

Removes a collision exception so the shape does report collisions with the specified [RID].

func (Instance) SetCollideWithAreas

func (self Instance) SetCollideWithAreas(value bool)

func (Instance) SetCollideWithBodies

func (self Instance) SetCollideWithBodies(value bool)

func (Instance) SetCollisionMask

func (self Instance) SetCollisionMask(value int)

func (Instance) SetCollisionMaskValue

func (self Instance) SetCollisionMaskValue(layer_number int, value bool)

Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.

func (Instance) SetEnabled

func (self Instance) SetEnabled(value bool)

func (Instance) SetExcludeParent

func (self Instance) SetExcludeParent(value bool)

func (Instance) SetMargin

func (self Instance) SetMargin(value Float.X)

func (Instance) SetMaxResults

func (self Instance) SetMaxResults(value int)

func (Instance) SetShape

func (self Instance) SetShape(value [1]gdclass.Shape2D)

func (Instance) SetTargetPosition

func (self Instance) SetTargetPosition(value Vector2.XY)

func (Instance) Shape

func (self Instance) Shape() [1]gdclass.Shape2D

func (Instance) TargetPosition

func (self Instance) TargetPosition() Vector2.XY

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL