Documentation
¶
Overview ¶
Package PhysicsBody2D provides methods for working with PhysicsBody2D object instances.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
- func (self *Extension[T]) AsCollisionObject2D() CollisionObject2D.Instance
- func (self *Extension[T]) AsNode() Node.Instance
- func (self *Extension[T]) AsNode2D() Node2D.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsPhysicsBody2D() Instance
- type ID
- type Instance
- func (self Instance) AddCollisionExceptionWith(body Node.Instance)
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsCollisionObject2D() CollisionObject2D.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Node2D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPhysicsBody2D() Instance
- func (self Instance) GetCollisionExceptions() []Instance
- func (self Instance) GetGravity() Vector2.XY
- func (self Instance) ID() ID
- func (self Instance) MoveAndCollide(motion Vector2.XY) KinematicCollision2D.Instance
- func (self Instance) RemoveCollisionExceptionWith(body Node.Instance)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) TestMove(from Transform2D.OriginXY, motion Vector2.XY) bool
- 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 Expanded ¶
type Expanded [1]gdclass.PhysicsBody2D
func (Expanded) MoveAndCollide ¶
func (self Expanded) MoveAndCollide(motion Vector2.XY, test_only bool, safe_margin Float.X, recovery_as_collision bool) KinematicCollision2D.Instance
Moves the body along the vector [param motion]. In order to be frame rate independent in [method Node._physics_process] or [method Node._process], [param motion] should be computed using [code]delta[/code]. Returns a [KinematicCollision2D], which contains information about the collision when stopped, or when touching another body along the motion. If [param test_only] is [code]true[/code], the body does not move but the would-be collision information is given. [param safe_margin] is the extra margin used for collision recovery (see [member CharacterBody2D.safe_margin] for more details). If [param recovery_as_collision] is [code]true[/code], any depenetration from the recovery phase is also reported as a collision; this is used e.g. by [CharacterBody2D] for improving floor detection during floor snapping.
func (Expanded) TestMove ¶
func (self Expanded) TestMove(from Transform2D.OriginXY, motion Vector2.XY, collision KinematicCollision2D.Instance, safe_margin Float.X, recovery_as_collision bool) bool
Checks for collisions without moving the body. In order to be frame rate independent in [method Node._physics_process] or [method Node._process], [param motion] should be computed using [code]delta[/code]. Virtually sets the node's position, scale and rotation to that of the given [Transform2D], then tries to move the body along the vector [param motion]. Returns [code]true[/code] if a collision would stop the body from moving along the whole path. [param collision] is an optional object of type [KinematicCollision2D], which contains additional information about the collision when stopped, or when touching another body along the motion. [param safe_margin] is the extra margin used for collision recovery (see [member CharacterBody2D.safe_margin] for more details). If [param recovery_as_collision] is [code]true[/code], any depenetration from the recovery phase is also reported as a collision; this is useful for checking whether the body would [i]touch[/i] any other bodies.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
func (*Extension[T]) AsCollisionObject2D ¶
func (self *Extension[T]) AsCollisionObject2D() CollisionObject2D.Instance
func (*Extension[T]) AsPhysicsBody2D ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.PhysicsBody2D
[PhysicsBody2D] is an abstract base class for 2D game objects affected by physics. All 2D physics bodies inherit from it.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AddCollisionExceptionWith ¶
Adds a body to the list of bodies that this body can't collide with.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsCollisionObject2D ¶
func (self Instance) AsCollisionObject2D() CollisionObject2D.Instance
func (Instance) AsPhysicsBody2D ¶
func (Instance) GetCollisionExceptions ¶
Returns an array of nodes that were added as collision exceptions for this body.
func (Instance) GetGravity ¶
Returns the gravity vector computed from all sources that can affect the body, including all gravity overrides from [Area2D] nodes and the global world gravity.
func (Instance) MoveAndCollide ¶
func (self Instance) MoveAndCollide(motion Vector2.XY) KinematicCollision2D.Instance
Moves the body along the vector [param motion]. In order to be frame rate independent in [method Node._physics_process] or [method Node._process], [param motion] should be computed using [code]delta[/code]. Returns a [KinematicCollision2D], which contains information about the collision when stopped, or when touching another body along the motion. If [param test_only] is [code]true[/code], the body does not move but the would-be collision information is given. [param safe_margin] is the extra margin used for collision recovery (see [member CharacterBody2D.safe_margin] for more details). If [param recovery_as_collision] is [code]true[/code], any depenetration from the recovery phase is also reported as a collision; this is used e.g. by [CharacterBody2D] for improving floor detection during floor snapping.
func (Instance) RemoveCollisionExceptionWith ¶
Removes a body from the list of bodies that this body can't collide with.
func (Instance) TestMove ¶
Checks for collisions without moving the body. In order to be frame rate independent in [method Node._physics_process] or [method Node._process], [param motion] should be computed using [code]delta[/code]. Virtually sets the node's position, scale and rotation to that of the given [Transform2D], then tries to move the body along the vector [param motion]. Returns [code]true[/code] if a collision would stop the body from moving along the whole path. [param collision] is an optional object of type [KinematicCollision2D], which contains additional information about the collision when stopped, or when touching another body along the motion. [param safe_margin] is the extra margin used for collision recovery (see [member CharacterBody2D.safe_margin] for more details). If [param recovery_as_collision] is [code]true[/code], any depenetration from the recovery phase is also reported as a collision; this is useful for checking whether the body would [i]touch[/i] any other bodies.