Documentation
¶
Overview ¶
graphics.gd/classdb/PhysicsBody3D is an abstract base class for 3D game objects affected by physics. All 3D physics bodies inherit from it.
Warning: With a non-uniform scale, this node will likely not behave as expected. It is advised to keep its scale the same on all axes and adjust its collision shape(s) instead.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AddCollisionExceptionWith(body Node.Instance)
- func (self Instance) AsCollisionObject3D() CollisionObject3D.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode3D() Node3D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPhysicsBody3D() Instance
- func (self Instance) AxisLockAngularX() bool
- func (self Instance) AxisLockAngularY() bool
- func (self Instance) AxisLockAngularZ() bool
- func (self Instance) AxisLockLinearX() bool
- func (self Instance) AxisLockLinearY() bool
- func (self Instance) AxisLockLinearZ() bool
- func (self Instance) GetCollisionExceptions() []Instance
- func (self Instance) GetGravity() Vector3.XYZ
- func (self Instance) ID() ID
- func (self Instance) MoveAndCollide(motion Vector3.XYZ) KinematicCollision3D.Instance
- func (self Instance) RemoveCollisionExceptionWith(body Node.Instance)
- func (self Instance) SetAxisLockAngularX(value bool)
- func (self Instance) SetAxisLockAngularY(value bool)
- func (self Instance) SetAxisLockAngularZ(value bool)
- func (self Instance) SetAxisLockLinearX(value bool)
- func (self Instance) SetAxisLockLinearY(value bool)
- func (self Instance) SetAxisLockLinearZ(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) TestMove(from Transform3D.BasisOrigin, motion Vector3.XYZ) bool
- 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.PhysicsBody3D
func (Expanded) MoveAndCollide ¶
func (self Expanded) MoveAndCollide(motion Vector3.XYZ, test_only bool, safe_margin Float.X, recovery_as_collision bool, max_collisions int) KinematicCollision3D.Instance
Moves the body along the vector 'motion'. In order to be frame rate independent in graphics.gd/classdb/Node.Instance.PhysicsProcess or graphics.gd/classdb/Node.Instance.Process, 'motion' should be computed using delta.
The body will stop if it collides. Returns a graphics.gd/classdb/KinematicCollision3D, which contains information about the collision when stopped, or when touching another body along the motion.
If 'test_only' is true, the body does not move but the would-be collision information is given.
'safe_margin' is the extra margin used for collision recovery (see graphics.gd/classdb/CharacterBody3D.Instance.SafeMargin for more details).
If 'recovery_as_collision' is true, any depenetration from the recovery phase is also reported as a collision; this is used e.g. by graphics.gd/classdb/CharacterBody3D for improving floor detection during floor snapping.
'max_collisions' allows to retrieve more than one collision result.
func (Expanded) TestMove ¶
func (self Expanded) TestMove(from Transform3D.BasisOrigin, motion Vector3.XYZ, collision KinematicCollision3D.Instance, safe_margin Float.X, recovery_as_collision bool, max_collisions int) bool
Checks for collisions without moving the body. In order to be frame rate independent in graphics.gd/classdb/Node.Instance.PhysicsProcess or graphics.gd/classdb/Node.Instance.Process, 'motion' should be computed using delta.
Virtually sets the node's position, scale and rotation to that of the given [Transform3D.BasisOrigin], then tries to move the body along the vector 'motion'. Returns true if a collision would stop the body from moving along the whole path.
'collision' is an optional object of type graphics.gd/classdb/KinematicCollision3D, which contains additional information about the collision when stopped, or when touching another body along the motion.
'safe_margin' is the extra margin used for collision recovery (see graphics.gd/classdb/CharacterBody3D.Instance.SafeMargin for more details).
If 'recovery_as_collision' is true, any depenetration from the recovery phase is also reported as a collision; this is useful for checking whether the body would touch any other bodies.
'max_collisions' allows to retrieve more than one collision result.
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]) AsCollisionObject3D ¶
func (self *Extension[T]) AsCollisionObject3D() CollisionObject3D.Instance
func (*Extension[T]) AsPhysicsBody3D ¶
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.PhysicsBody3D
Instance of the class with convieniently typed arguments and results.
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) AsCollisionObject3D ¶
func (self Instance) AsCollisionObject3D() CollisionObject3D.Instance
func (Instance) AsPhysicsBody3D ¶
func (Instance) AxisLockAngularX ¶
func (Instance) AxisLockAngularY ¶
func (Instance) AxisLockAngularZ ¶
func (Instance) AxisLockLinearX ¶
func (Instance) AxisLockLinearY ¶
func (Instance) AxisLockLinearZ ¶
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 graphics.gd/classdb/Area3D nodes and the global world gravity.
func (Instance) MoveAndCollide ¶
func (self Instance) MoveAndCollide(motion Vector3.XYZ) KinematicCollision3D.Instance
Moves the body along the vector 'motion'. In order to be frame rate independent in graphics.gd/classdb/Node.Instance.PhysicsProcess or graphics.gd/classdb/Node.Instance.Process, 'motion' should be computed using delta.
The body will stop if it collides. Returns a graphics.gd/classdb/KinematicCollision3D, which contains information about the collision when stopped, or when touching another body along the motion.
If 'test_only' is true, the body does not move but the would-be collision information is given.
'safe_margin' is the extra margin used for collision recovery (see graphics.gd/classdb/CharacterBody3D.Instance.SafeMargin for more details).
If 'recovery_as_collision' is true, any depenetration from the recovery phase is also reported as a collision; this is used e.g. by graphics.gd/classdb/CharacterBody3D for improving floor detection during floor snapping.
'max_collisions' allows to retrieve more than one collision result.
func (Instance) RemoveCollisionExceptionWith ¶
Removes a body from the list of bodies that this body can't collide with.
func (Instance) SetAxisLockAngularX ¶
func (Instance) SetAxisLockAngularY ¶
func (Instance) SetAxisLockAngularZ ¶
func (Instance) SetAxisLockLinearX ¶
func (Instance) SetAxisLockLinearY ¶
func (Instance) SetAxisLockLinearZ ¶
func (Instance) TestMove ¶
func (self Instance) TestMove(from Transform3D.BasisOrigin, motion Vector3.XYZ) bool
Checks for collisions without moving the body. In order to be frame rate independent in graphics.gd/classdb/Node.Instance.PhysicsProcess or graphics.gd/classdb/Node.Instance.Process, 'motion' should be computed using delta.
Virtually sets the node's position, scale and rotation to that of the given [Transform3D.BasisOrigin], then tries to move the body along the vector 'motion'. Returns true if a collision would stop the body from moving along the whole path.
'collision' is an optional object of type graphics.gd/classdb/KinematicCollision3D, which contains additional information about the collision when stopped, or when touching another body along the motion.
'safe_margin' is the extra margin used for collision recovery (see graphics.gd/classdb/CharacterBody3D.Instance.SafeMargin for more details).
If 'recovery_as_collision' is true, any depenetration from the recovery phase is also reported as a collision; this is useful for checking whether the body would touch any other bodies.
'max_collisions' allows to retrieve more than one collision result.