Documentation
¶
Overview ¶
Abstract base class for 3D physics objects. CollisionObject3D can hold any number of Shape3Ds for collision. Each shape must be assigned to a shape owner. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the shape_owner_* methods.
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 DisableMode
- type Extension
- type ID
- type Implementation
- type Instance
- func (self Instance) AsCollisionObject3D() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode3D() Node3D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) CollisionLayer() int
- func (self Instance) CollisionMask() int
- func (self Instance) CollisionPriority() Float.X
- func (self Instance) CreateShapeOwner(owner Object.Instance) int
- func (self Instance) DisableMode() DisableMode
- func (self Instance) GetCollisionLayerValue(layer_number int) bool
- func (self Instance) GetCollisionMaskValue(layer_number int) bool
- func (self Instance) GetRid() RID.Body3D
- func (self Instance) GetShapeOwners() []int32
- func (self Instance) ID() ID
- func (self Instance) InputCaptureOnDrag() bool
- func (self Instance) InputRayPickable() bool
- func (self Instance) IsShapeOwnerDisabled(owner_id int) bool
- func (self Instance) OnInputEvent(...)
- func (self Instance) OnMouseEntered(cb func(), flags ...Signal.Flags)
- func (self Instance) OnMouseExited(cb func(), flags ...Signal.Flags)
- func (self Instance) RemoveShapeOwner(owner_id int)
- func (self Instance) SetCollisionLayer(value int)
- func (self Instance) SetCollisionLayerValue(layer_number int, value bool)
- func (self Instance) SetCollisionMask(value int)
- func (self Instance) SetCollisionMaskValue(layer_number int, value bool)
- func (self Instance) SetCollisionPriority(value Float.X)
- func (self Instance) SetDisableMode(value DisableMode)
- func (self Instance) SetInputCaptureOnDrag(value bool)
- func (self Instance) SetInputRayPickable(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) ShapeFindOwner(shape_index int) int
- func (self Instance) ShapeOwnerAddShape(owner_id int, shape Shape3D.Instance)
- func (self Instance) ShapeOwnerClearShapes(owner_id int)
- func (self Instance) ShapeOwnerGetOwner(owner_id int) Object.Instance
- func (self Instance) ShapeOwnerGetShape(owner_id int, shape_id int) Shape3D.Instance
- func (self Instance) ShapeOwnerGetShapeCount(owner_id int) int
- func (self Instance) ShapeOwnerGetShapeIndex(owner_id int, shape_id int) int
- func (self Instance) ShapeOwnerGetTransform(owner_id int) Transform3D.BasisOrigin
- func (self Instance) ShapeOwnerRemoveShape(owner_id int, shape_id int)
- func (self Instance) ShapeOwnerSetDisabled(owner_id int, disabled bool)
- func (self Instance) ShapeOwnerSetTransform(owner_id int, transform Transform3D.BasisOrigin)
- func (self Instance) Virtual(name string) reflect.Value
- type Interface
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 DisableMode ¶
type DisableMode int //gd:CollisionObject3D.DisableMode
const ( // When [Node.ProcessMode] is set to [Node.ProcessModeDisabled], remove from the physics simulation to stop all physics interactions with this [CollisionObject3D]. // // Automatically re-added to the physics simulation when the [Node] is processed again. // // [CollisionObject3D]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D // [Node]: https://pkg.go.dev/graphics.gd/classdb/Node // [Node.ProcessMode]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.ProcessMode DisableModeRemove DisableMode = 0 // When [Node.ProcessMode] is set to [Node.ProcessModeDisabled], make the body static. Doesn't affect [Area3D]. [PhysicsBody3D] can't be affected by forces or other bodies while static. // // Automatically set [PhysicsBody3D] back to its original mode when the [Node] is processed again. // // [Area3D]: https://pkg.go.dev/graphics.gd/classdb/Area3D // [Node]: https://pkg.go.dev/graphics.gd/classdb/Node // [Node.ProcessMode]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.ProcessMode // [PhysicsBody3D]: https://pkg.go.dev/graphics.gd/classdb/PhysicsBody3D DisableModeMakeStatic DisableMode = 1 // When [Node.ProcessMode] is set to [Node.ProcessModeDisabled], do not affect the physics simulation. // // [Node.ProcessMode]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.ProcessMode DisableModeKeepActive DisableMode = 2 )
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]See Interface for methods that can be overridden by T.
func (*Extension[T]) AsCollisionObject3D ¶
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 Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
type Instance [1]gdclass.CollisionObject3D
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) AsCollisionObject3D ¶
func (Instance) CollisionLayer ¶
The physics layers this CollisionObject3D is in. Collision objects can exist in one or more of 32 different layers. See also CollisionMask.
Note: Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See Collision layers and masks in the documentation for more information.
func (Instance) CollisionMask ¶
The physics layers this CollisionObject3D scans. Collision objects can scan one or more of 32 different layers. See also CollisionLayer.
Note: Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See Collision layers and masks in the documentation for more information.
func (Instance) CollisionPriority ¶
The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
func (Instance) CreateShapeOwner ¶
Creates a new shape owner for the given object. Returns owner_id of the new owner for future reference.
func (Instance) DisableMode ¶
func (self Instance) DisableMode() DisableMode
Defines the behavior in physics when Node.ProcessMode is set to [Node.ProcessModeDisabled].
func (Instance) GetCollisionLayerValue ¶
Returns whether or not the specified layer of the CollisionLayer is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetCollisionMaskValue ¶
Returns whether or not the specified layer of the CollisionMask is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetShapeOwners ¶
Returns an slice of owner_id identifiers. You can use these ids in other methods that take owner_id as an argument.
func (Instance) InputCaptureOnDrag ¶
If true, the CollisionObject3D will continue to receive input events as the mouse is dragged across its shapes.
func (Instance) InputRayPickable ¶
If true, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one CollisionLayer bit to be set.
func (Instance) IsShapeOwnerDisabled ¶
If true, the shape owner and its shapes are disabled.
func (Instance) OnInputEvent ¶
func (self Instance) OnInputEvent(cb func(camera Node.Instance, event InputEvent.Instance, event_position Vector3.XYZ, normal Vector3.XYZ, shape_idx int), flags ...Signal.Flags)
Emitted when the object receives an unhandled InputEvent. 'event_position' is the location in world space of the mouse pointer on the surface of the shape with index 'shape_idx' and 'normal' is the normal vector of the surface at that point.
func (Instance) OnMouseEntered ¶
Emitted when the mouse pointer enters any of this object's shapes. Requires InputRayPickable to be true and at least one CollisionLayer bit to be set.
Note: Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the CollisionObject3D's area is small. This signal may also not be emitted if another CollisionObject3D is overlapping the CollisionObject3D in question.
func (Instance) OnMouseExited ¶
Emitted when the mouse pointer exits all this object's shapes. Requires InputRayPickable to be true and at least one CollisionLayer bit to be set.
Note: Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the CollisionObject3D's area is small. This signal may also not be emitted if another CollisionObject3D is overlapping the CollisionObject3D in question.
func (Instance) RemoveShapeOwner ¶
Removes the given shape owner.
func (Instance) SetCollisionLayer ¶
SetCollisionLayer sets the property returned by [GetCollisionLayer].
func (Instance) SetCollisionLayerValue ¶
Based on 'value', enables or disables the specified layer in the CollisionLayer, given a 'layer_number' between 1 and 32.
func (Instance) SetCollisionMask ¶
SetCollisionMask sets the property returned by [GetCollisionMask].
func (Instance) SetCollisionMaskValue ¶
Based on 'value', enables or disables the specified layer in the CollisionMask, given a 'layer_number' between 1 and 32.
func (Instance) SetCollisionPriority ¶
SetCollisionPriority sets the property returned by [GetCollisionPriority].
func (Instance) SetDisableMode ¶
func (self Instance) SetDisableMode(value DisableMode)
SetDisableMode sets the property returned by [GetDisableMode].
func (Instance) SetInputCaptureOnDrag ¶
SetInputCaptureOnDrag sets the property returned by [GetCaptureInputOnDrag].
func (Instance) SetInputRayPickable ¶
SetInputRayPickable sets the property returned by [IsRayPickable].
func (Instance) ShapeFindOwner ¶
Returns the owner_id of the given shape.
func (Instance) ShapeOwnerAddShape ¶
Adds a Shape3D to the shape owner.
func (Instance) ShapeOwnerClearShapes ¶
Removes all shapes from the shape owner.
func (Instance) ShapeOwnerGetOwner ¶
Returns the parent object of the given shape owner.
func (Instance) ShapeOwnerGetShape ¶
Returns the Shape3D with the given ID from the given shape owner.
func (Instance) ShapeOwnerGetShapeCount ¶
Returns the number of shapes the given shape owner contains.
func (Instance) ShapeOwnerGetShapeIndex ¶
Returns the child index of the Shape3D with the given ID from the given shape owner.
func (Instance) ShapeOwnerGetTransform ¶
func (self Instance) ShapeOwnerGetTransform(owner_id int) Transform3D.BasisOrigin
Returns the shape owner's Transform3D.BasisOrigin.
func (Instance) ShapeOwnerRemoveShape ¶
Removes a shape from the given shape owner.
func (Instance) ShapeOwnerSetDisabled ¶
If true, disables the given shape owner.
func (Instance) ShapeOwnerSetTransform ¶
func (self Instance) ShapeOwnerSetTransform(owner_id int, transform Transform3D.BasisOrigin)
Sets the Transform3D.BasisOrigin of the given shape owner.
type Interface ¶
type Interface interface { // Receives unhandled [InputEvent]s. 'event_position' is the location in world space of the mouse pointer on the surface of the shape with index 'shape_idx' and 'normal' is the normal vector of the surface at that point. Connect to the [OnInputEvent] signal to easily pick up these events. // // Note: [InputEvent] requires [InputRayPickable] to be true and at least one [CollisionLayer] bit to be set. // // [CollisionLayer]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Instance.CollisionLayer // [InputEvent]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Interface // [InputRayPickable]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Instance.InputRayPickable // [OnInputEvent]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Instance.OnInputEvent InputEvent(camera Camera3D.Instance, event InputEvent.Instance, event_position Vector3.XYZ, normal Vector3.XYZ, shape_idx int) // Called when the mouse pointer enters any of this object's shapes. Requires [InputRayPickable] to be true and at least one [CollisionLayer] bit to be set. Note that moving between different shapes within a single [CollisionObject3D] won't cause this function to be called. // // [CollisionLayer]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Instance.CollisionLayer // [CollisionObject3D]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D // [InputRayPickable]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Instance.InputRayPickable MouseEnter() // Called when the mouse pointer exits all this object's shapes. Requires [InputRayPickable] to be true and at least one [CollisionLayer] bit to be set. Note that moving between different shapes within a single [CollisionObject3D] won't cause this function to be called. // // [CollisionLayer]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Instance.CollisionLayer // [CollisionObject3D]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D // [InputRayPickable]: https://pkg.go.dev/graphics.gd/classdb/CollisionObject3D#Instance.InputRayPickable MouseExit() }