PhysicsDirectBodyState3D

package
v0.0.0-...-0d6c339 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Provides direct access to a physics body in the graphics.gd/classdb/PhysicsServer3D, allowing safe changes to physics properties. This object is passed via the direct state callback of graphics.gd/classdb/RigidBody3D, and is intended for changing the direct state of that body. See graphics.gd/classdb/RigidBody3D.Instance.IntegrateForces.

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
	AsPhysicsDirectBodyState3D() Instance
}

type Expanded

func (Expanded) AddConstantCentralForce

func (self Expanded) AddConstantCentralForce(force Vector3.XYZ)

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 Instance.AddConstantForce at the body's center of mass.

func (Expanded) AddConstantForce

func (self Expanded) AddConstantForce(force Vector3.XYZ, position Vector3.XYZ)

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 (Expanded) ApplyCentralForce

func (self Expanded) ApplyCentralForce(force Vector3.XYZ)

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 Instance.ApplyForce at the body's center of mass.

func (Expanded) ApplyCentralImpulse

func (self Expanded) ApplyCentralImpulse(impulse Vector3.XYZ)

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 Instance.ApplyImpulse at the body's center of mass.

func (Expanded) ApplyForce

func (self Expanded) ApplyForce(force Vector3.XYZ, position Vector3.XYZ)

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 (Expanded) ApplyImpulse

func (self Expanded) ApplyImpulse(impulse Vector3.XYZ, position Vector3.XYZ)

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.

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsPhysicsDirectBodyState3D

func (self *Extension[T]) AsPhysicsDirectBodyState3D() Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

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 New

func New() Instance

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 Instance.AddConstantForce at the body's center of mass.

func (Instance) AddConstantForce

func (self Instance) AddConstantForce(force Vector3.XYZ)

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

func (self Instance) AddConstantTorque(torque Vector3.XYZ)

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

func (self Instance) AngularVelocity() Vector3.XYZ

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 Instance.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 Instance.ApplyImpulse at the body's center of mass.

func (Instance) ApplyForce

func (self Instance) ApplyForce(force Vector3.XYZ)

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

func (self Instance) ApplyImpulse(impulse Vector3.XYZ)

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

func (self Instance) ApplyTorque(torque Vector3.XYZ)

Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.

Note: Instance.InverseInertia is required for this to work. To have Instance.InverseInertia, an active graphics.gd/classdb/CollisionShape3D must be a child of the node, or you can manually set Instance.InverseInertia.

func (Instance) ApplyTorqueImpulse

func (self Instance) ApplyTorqueImpulse(impulse Vector3.XYZ)

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: Instance.InverseInertia is required for this to work. To have Instance.InverseInertia, an active graphics.gd/classdb/CollisionShape3D must be a child of the node, or you can manually set Instance.InverseInertia.

func (Instance) AsObject

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

func (Instance) AsPhysicsDirectBodyState3D

func (self Instance) AsPhysicsDirectBodyState3D() Instance

func (Instance) CenterOfMass

func (self Instance) CenterOfMass() Vector3.XYZ

func (Instance) CenterOfMassLocal

func (self Instance) CenterOfMassLocal() Vector3.XYZ

func (Instance) CollisionLayer

func (self Instance) CollisionLayer() int

func (Instance) CollisionMask

func (self Instance) CollisionMask() int

func (Instance) GetConstantForce

func (self Instance) GetConstantForce() Vector3.XYZ

Returns the body's total constant positional forces applied during each physics update.

See Instance.AddConstantForce and Instance.AddConstantCentralForce.

func (Instance) GetConstantTorque

func (self Instance) GetConstantTorque() Vector3.XYZ

Returns the body's total constant rotational forces applied during each physics update.

See Instance.AddConstantTorque.

func (Instance) GetContactCollider

func (self Instance) GetContactCollider(contact_idx int) RID.Body3D

Returns the collider's [Resource.ID].

func (Instance) GetContactColliderId

func (self Instance) GetContactColliderId(contact_idx int) int

Returns the collider's object id.

func (Instance) GetContactColliderObject

func (self Instance) GetContactColliderObject(contact_idx int) Object.Instance

Returns the collider object.

func (Instance) GetContactColliderPosition

func (self Instance) GetContactColliderPosition(contact_idx int) Vector3.XYZ

Returns the position of the contact point on the collider in the global coordinate system.

func (Instance) GetContactColliderShape

func (self Instance) GetContactColliderShape(contact_idx int) int

Returns the collider's shape index.

func (Instance) GetContactColliderVelocityAtPosition

func (self Instance) GetContactColliderVelocityAtPosition(contact_idx int) Vector3.XYZ

Returns the linear velocity vector at the collider's contact point.

func (Instance) GetContactCount

func (self Instance) GetContactCount() int

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 graphics.gd/classdb/RigidBody3D.Instance.ContactMonitor.

func (Instance) GetContactImpulse

func (self Instance) GetContactImpulse(contact_idx int) Vector3.XYZ

Impulse created by the contact.

func (Instance) GetContactLocalNormal

func (self Instance) GetContactLocalNormal(contact_idx int) Vector3.XYZ

Returns the local normal at the contact point.

func (Instance) GetContactLocalPosition

func (self Instance) GetContactLocalPosition(contact_idx int) Vector3.XYZ

Returns the position of the contact point on the body in the global coordinate system.

func (Instance) GetContactLocalShape

func (self Instance) GetContactLocalShape(contact_idx int) int

Returns the local shape index of the collision.

func (Instance) GetContactLocalVelocityAtPosition

func (self Instance) GetContactLocalVelocityAtPosition(contact_idx int) Vector3.XYZ

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

func (self Instance) GetVelocityAtLocalPosition(local_position Vector3.XYZ) Vector3.XYZ

Returns the body's velocity at the given relative position, including both translation and rotation.

func (Instance) ID

func (self Instance) ID() ID

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

func (self Instance) InverseInertia() Vector3.XYZ

func (Instance) InverseInertiaTensor

func (self Instance) InverseInertiaTensor() Basis.XYZ

func (Instance) InverseMass

func (self Instance) InverseMass() Float.X

func (Instance) LinearVelocity

func (self Instance) LinearVelocity() Vector3.XYZ

func (Instance) PrincipalInertiaAxes

func (self Instance) PrincipalInertiaAxes() Basis.XYZ

func (Instance) SetAngularVelocity

func (self Instance) SetAngularVelocity(value Vector3.XYZ)

func (Instance) SetCollisionLayer

func (self Instance) SetCollisionLayer(value int)

func (Instance) SetCollisionMask

func (self Instance) SetCollisionMask(value int)

func (Instance) SetConstantForce

func (self Instance) SetConstantForce(force Vector3.XYZ)

Sets the body's total constant positional forces applied during each physics update.

See Instance.AddConstantForce and Instance.AddConstantCentralForce.

func (Instance) SetConstantTorque

func (self Instance) SetConstantTorque(torque Vector3.XYZ)

Sets the body's total constant rotational forces applied during each physics update.

See Instance.AddConstantTorque.

func (Instance) SetLinearVelocity

func (self Instance) SetLinearVelocity(value Vector3.XYZ)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetSleeping

func (self Instance) SetSleeping(value bool)

func (Instance) SetTransform

func (self Instance) SetTransform(value Transform3D.BasisOrigin)

func (Instance) Sleeping

func (self Instance) Sleeping() bool

func (Instance) Step

func (self Instance) Step() Float.X

func (Instance) TotalAngularDamp

func (self Instance) TotalAngularDamp() Float.X

func (Instance) TotalGravity

func (self Instance) TotalGravity() Vector3.XYZ

func (Instance) TotalLinearDamp

func (self Instance) TotalLinearDamp() Float.X

func (Instance) Transform

func (self Instance) Transform() Transform3D.BasisOrigin

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