Documentation
¶
Overview ¶
Provides direct access to a physics body in the PhysicsServer3D, allowing safe changes to physics properties. This object is passed via the direct state callback of RigidBody3D, and is intended for changing the direct state of that body. See RigidBody3D.IntegrateForces.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AddConstantCentralForce()
- func (self Instance) AddConstantForce(force Vector3.XYZ)
- func (self Instance) AddConstantTorque(torque Vector3.XYZ)
- func (self Instance) AngularVelocity() Vector3.XYZ
- func (self Instance) ApplyCentralForce()
- func (self Instance) ApplyCentralImpulse()
- func (self Instance) ApplyForce(force Vector3.XYZ)
- func (self Instance) ApplyImpulse(impulse Vector3.XYZ)
- func (self Instance) ApplyTorque(torque Vector3.XYZ)
- func (self Instance) ApplyTorqueImpulse(impulse Vector3.XYZ)
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPhysicsDirectBodyState3D() Instance
- func (self Instance) CenterOfMass() Vector3.XYZ
- func (self Instance) CenterOfMassLocal() Vector3.XYZ
- func (self Instance) CollisionLayer() int
- func (self Instance) CollisionMask() int
- func (self Instance) GetConstantForce() Vector3.XYZ
- func (self Instance) GetConstantTorque() Vector3.XYZ
- func (self Instance) GetContactCollider(contact_idx int) RID.Body3D
- func (self Instance) GetContactColliderId(contact_idx int) int
- func (self Instance) GetContactColliderObject(contact_idx int) Object.Instance
- func (self Instance) GetContactColliderPosition(contact_idx int) Vector3.XYZ
- func (self Instance) GetContactColliderShape(contact_idx int) int
- func (self Instance) GetContactColliderVelocityAtPosition(contact_idx int) Vector3.XYZ
- func (self Instance) GetContactCount() int
- func (self Instance) GetContactImpulse(contact_idx int) Vector3.XYZ
- func (self Instance) GetContactLocalNormal(contact_idx int) Vector3.XYZ
- func (self Instance) GetContactLocalPosition(contact_idx int) Vector3.XYZ
- func (self Instance) GetContactLocalShape(contact_idx int) int
- func (self Instance) GetContactLocalVelocityAtPosition(contact_idx int) Vector3.XYZ
- func (self Instance) GetSpaceState() PhysicsDirectSpaceState3D.Instance
- func (self Instance) GetVelocityAtLocalPosition(local_position Vector3.XYZ) Vector3.XYZ
- func (self Instance) ID() ID
- func (self Instance) IntegrateForces()
- func (self Instance) InverseInertia() Vector3.XYZ
- func (self Instance) InverseInertiaTensor() Basis.XYZ
- func (self Instance) InverseMass() Float.X
- func (self Instance) LinearVelocity() Vector3.XYZ
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) PrincipalInertiaAxes() Basis.XYZ
- func (self Instance) SetAngularVelocity(value Vector3.XYZ)
- func (self Instance) SetCollisionLayer(value int)
- func (self Instance) SetCollisionMask(value int)
- func (self Instance) SetConstantForce(force Vector3.XYZ)
- func (self Instance) SetConstantTorque(torque Vector3.XYZ)
- func (self Instance) SetLinearVelocity(value Vector3.XYZ)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSleeping(value bool)
- func (self Instance) SetTransform(value Transform3D.BasisOrigin)
- func (self Instance) Sleeping() bool
- func (self Instance) Step() Float.X
- func (self Instance) TotalAngularDamp() Float.X
- func (self Instance) TotalGravity() Vector3.XYZ
- func (self Instance) TotalLinearDamp() Float.X
- func (self Instance) Transform() Transform3D.BasisOrigin
- func (self Instance) Virtual(name string) reflect.Value
- type MoreArgs
- func (self MoreArgs) AddConstantCentralForce(force Vector3.XYZ)
- func (self MoreArgs) AddConstantForce(force Vector3.XYZ, position Vector3.XYZ)
- func (self MoreArgs) ApplyCentralForce(force Vector3.XYZ)
- func (self MoreArgs) ApplyCentralImpulse(impulse Vector3.XYZ)
- func (self MoreArgs) ApplyForce(force Vector3.XYZ, position Vector3.XYZ)
- func (self MoreArgs) ApplyImpulse(impulse Vector3.XYZ, position Vector3.XYZ)
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 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]) AsPhysicsDirectBodyState3D ¶
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.PhysicsDirectBodyState3D
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) AddConstantCentralForce ¶
func (self Instance) AddConstantCentralForce()
Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).
This is equivalent to using AddConstantForce at the body's center of mass.
func (Instance) AddConstantForce ¶
Adds a constant positioned force to the body that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).
'position' is the offset from the body origin in global coordinates.
func (Instance) AddConstantTorque ¶
Adds a constant rotational force without affecting position that keeps being applied over time until cleared with constant_torque = Vector3(0, 0, 0).
func (Instance) AngularVelocity ¶
The body's rotational velocity in radians per second.
func (Instance) ApplyCentralForce ¶
func (self Instance) ApplyCentralForce()
Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
This is equivalent to using ApplyForce at the body's center of mass.
func (Instance) ApplyCentralImpulse ¶
func (self Instance) ApplyCentralImpulse()
Applies a directional impulse without affecting rotation.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
This is equivalent to using ApplyImpulse at the body's center of mass.
func (Instance) ApplyForce ¶
Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
'position' is the offset from the body origin in global coordinates.
func (Instance) ApplyImpulse ¶
Applies a positioned impulse to the body.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
'position' is the offset from the body origin in global coordinates.
func (Instance) ApplyTorque ¶
Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
Note: InverseInertia is required for this to work. To have InverseInertia, an active CollisionShape3D must be a child of the node, or you can manually set InverseInertia.
func (Instance) ApplyTorqueImpulse ¶
Applies a rotational impulse to the body without affecting the position.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
Note: InverseInertia is required for this to work. To have InverseInertia, an active CollisionShape3D must be a child of the node, or you can manually set InverseInertia.
func (Instance) AsPhysicsDirectBodyState3D ¶
func (Instance) CenterOfMass ¶
The body's center of mass position relative to the body's center in the global coordinate system.
func (Instance) CenterOfMassLocal ¶
The body's center of mass position in the body's local coordinate system.
func (Instance) CollisionLayer ¶
The body's collision layer.
func (Instance) GetConstantForce ¶
Returns the body's total constant positional forces applied during each physics update.
See AddConstantForce and AddConstantCentralForce.
func (Instance) GetConstantTorque ¶
Returns the body's total constant rotational forces applied during each physics update.
See AddConstantTorque.
func (Instance) GetContactCollider ¶
Returns the collider's Resource.ID.
func (Instance) GetContactColliderId ¶
Returns the collider's object id.
func (Instance) GetContactColliderObject ¶
Returns the collider object.
func (Instance) GetContactColliderPosition ¶
Returns the position of the contact point on the collider in the global coordinate system.
func (Instance) GetContactColliderShape ¶
Returns the collider's shape index.
func (Instance) GetContactColliderVelocityAtPosition ¶
Returns the linear velocity vector at the collider's contact point.
func (Instance) GetContactCount ¶
Returns the number of contacts this body has with other bodies.
Note: By default, this returns 0 unless bodies are configured to monitor contacts. See RigidBody3D.ContactMonitor.
func (Instance) GetContactImpulse ¶
Impulse created by the contact.
func (Instance) GetContactLocalNormal ¶
Returns the local normal at the contact point.
func (Instance) GetContactLocalPosition ¶
Returns the position of the contact point on the body in the global coordinate system.
func (Instance) GetContactLocalShape ¶
Returns the local shape index of the collision.
func (Instance) GetContactLocalVelocityAtPosition ¶
Returns the linear velocity vector at the body's contact point.
func (Instance) GetSpaceState ¶
func (self Instance) GetSpaceState() PhysicsDirectSpaceState3D.Instance
Returns the current state of the space, useful for queries.
func (Instance) GetVelocityAtLocalPosition ¶
Returns the body's velocity at the given relative position, including both translation and rotation.
func (Instance) IntegrateForces ¶
func (self Instance) IntegrateForces()
Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
func (Instance) InverseInertia ¶
The inverse of the inertia of the body.
func (Instance) InverseInertiaTensor ¶
The inverse of the inertia tensor of the body.
func (Instance) InverseMass ¶
The inverse of the mass of the body.
func (Instance) LinearVelocity ¶
The body's linear velocity in units per second.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) PrincipalInertiaAxes ¶
func (Instance) SetAngularVelocity ¶
SetAngularVelocity sets the property returned by [GetAngularVelocity].
func (Instance) SetCollisionLayer ¶
SetCollisionLayer sets the property returned by [GetCollisionLayer].
func (Instance) SetCollisionMask ¶
SetCollisionMask sets the property returned by [GetCollisionMask].
func (Instance) SetConstantForce ¶
Sets the body's total constant positional forces applied during each physics update.
See AddConstantForce and AddConstantCentralForce.
func (Instance) SetConstantTorque ¶
Sets the body's total constant rotational forces applied during each physics update.
See AddConstantTorque.
func (Instance) SetLinearVelocity ¶
SetLinearVelocity sets the property returned by [GetLinearVelocity].
func (Instance) SetSleeping ¶
SetSleeping sets the property returned by [IsSleeping].
func (Instance) SetTransform ¶
func (self Instance) SetTransform(value Transform3D.BasisOrigin)
SetTransform sets the property returned by [GetTransform].
func (Instance) TotalAngularDamp ¶
The rate at which the body stops rotating, if there are not any other forces moving it.
func (Instance) TotalGravity ¶
The total gravity vector being currently applied to this body.
func (Instance) TotalLinearDamp ¶
The rate at which the body stops moving, if there are not any other forces moving it.
func (Instance) Transform ¶
func (self Instance) Transform() Transform3D.BasisOrigin
The body's transformation matrix.
type MoreArgs ¶
type MoreArgs [1]gdclass.PhysicsDirectBodyState3D
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) AddConstantCentralForce ¶
Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).
This is equivalent to using AddConstantForce at the body's center of mass.
func (MoreArgs) AddConstantForce ¶
Adds a constant positioned force to the body that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).
'position' is the offset from the body origin in global coordinates.
func (MoreArgs) ApplyCentralForce ¶
Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
This is equivalent to using ApplyForce at the body's center of mass.
func (MoreArgs) ApplyCentralImpulse ¶
Applies a directional impulse without affecting rotation.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
This is equivalent to using ApplyImpulse at the body's center of mass.
func (MoreArgs) ApplyForce ¶
Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
'position' is the offset from the body origin in global coordinates.
func (MoreArgs) ApplyImpulse ¶
Applies a positioned impulse to the body.
An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
'position' is the offset from the body origin in global coordinates.