CharacterBody3D

package
v0.0.0-...-ae8aae0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package CharacterBody3D provides methods for working with CharacterBody3D object instances.

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

type Instance

type Instance [1]gdclass.CharacterBody3D

[CharacterBody3D] is a specialized class for physics bodies that are meant to be user-controlled. They are not affected by physics at all, but they affect other physics bodies in their path. They are mainly used to provide high-level API to move objects with wall and slope detection ([method move_and_slide] method) in addition to the general collision detection provided by [method PhysicsBody3D.move_and_collide]. This makes it useful for highly configurable physics bodies that must move in specific ways and collide with the world, as is often the case with user-controlled characters. For game objects that don't require complex movement or collision detection, such as moving platforms, [AnimatableBody3D] is simpler to configure.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) ApplyFloorSnap

func (self Instance) ApplyFloorSnap()

Allows to manually apply a snap to the floor regardless of the body's velocity. This function does nothing when [method is_on_floor] returns [code]true[/code].

func (Instance) AsCharacterBody3D

func (self Instance) AsCharacterBody3D() Instance

func (Instance) AsCollisionObject3D

func (self Instance) AsCollisionObject3D() CollisionObject3D.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode3D

func (self Instance) AsNode3D() Node3D.Instance

func (Instance) AsObject

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

func (Instance) AsPhysicsBody3D

func (self Instance) AsPhysicsBody3D() PhysicsBody3D.Instance

func (Instance) FloorBlockOnWall

func (self Instance) FloorBlockOnWall() bool

func (Instance) FloorConstantSpeed

func (self Instance) FloorConstantSpeed() bool

func (Instance) FloorMaxAngle

func (self Instance) FloorMaxAngle() Float.X

func (Instance) FloorSnapLength

func (self Instance) FloorSnapLength() Float.X

func (Instance) FloorStopOnSlope

func (self Instance) FloorStopOnSlope() bool

func (Instance) GetFloorAngle

func (self Instance) GetFloorAngle() Float.X

Returns the floor's collision angle at the last collision point according to [param up_direction], which is [constant Vector3.UP] by default. This value is always positive and only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code].

func (Instance) GetFloorNormal

func (self Instance) GetFloorNormal() Vector3.XYZ

Returns the collision normal of the floor at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_floor] returns [code]true[/code]. [b]Warning:[/b] The collision normal is not always the same as the surface normal.

func (Instance) GetLastMotion

func (self Instance) GetLastMotion() Vector3.XYZ

Returns the last motion applied to the [CharacterBody3D] during the last call to [method move_and_slide]. The movement can be split into multiple motions when sliding occurs, and this method return the last one, which is useful to retrieve the current direction of the movement.

func (Instance) GetLastSlideCollision

func (self Instance) GetLastSlideCollision() [1]gdclass.KinematicCollision3D

Returns a [KinematicCollision3D], which contains information about the latest collision that occurred during the last call to [method move_and_slide].

func (Instance) GetPlatformAngularVelocity

func (self Instance) GetPlatformAngularVelocity() Vector3.XYZ

Returns the angular velocity of the platform at the last collision point. Only valid after calling [method move_and_slide].

func (Instance) GetPlatformVelocity

func (self Instance) GetPlatformVelocity() Vector3.XYZ

Returns the linear velocity of the platform at the last collision point. Only valid after calling [method move_and_slide].

func (Instance) GetPositionDelta

func (self Instance) GetPositionDelta() Vector3.XYZ

Returns the travel (position delta) that occurred during the last call to [method move_and_slide].

func (Instance) GetRealVelocity

func (self Instance) GetRealVelocity() Vector3.XYZ

Returns the current real velocity since the last call to [method move_and_slide]. For example, when you climb a slope, you will move diagonally even though the velocity is horizontal. This method returns the diagonal movement, as opposed to [member velocity] which returns the requested velocity.

func (Instance) GetSlideCollision

func (self Instance) GetSlideCollision(slide_idx int) [1]gdclass.KinematicCollision3D

Returns a [KinematicCollision3D], which contains information about a collision that occurred during the last call to [method move_and_slide]. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_collision_count] - 1).

func (Instance) GetSlideCollisionCount

func (self Instance) GetSlideCollisionCount() int

Returns the number of times the body collided and changed direction during the last call to [method move_and_slide].

func (Instance) GetWallNormal

func (self Instance) GetWallNormal() Vector3.XYZ

Returns the collision normal of the wall at the last collision point. Only valid after calling [method move_and_slide] and when [method is_on_wall] returns [code]true[/code]. [b]Warning:[/b] The collision normal is not always the same as the surface normal.

func (Instance) IsOnCeiling

func (self Instance) IsOnCeiling() bool

Returns [code]true[/code] if the body collided with the ceiling on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. The [member up_direction] and [member floor_max_angle] are used to determine whether a surface is "ceiling" or not.

func (Instance) IsOnCeilingOnly

func (self Instance) IsOnCeilingOnly() bool

Returns [code]true[/code] if the body collided only with the ceiling on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. The [member up_direction] and [member floor_max_angle] are used to determine whether a surface is "ceiling" or not.

func (Instance) IsOnFloor

func (self Instance) IsOnFloor() bool

Returns [code]true[/code] if the body collided with the floor on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. The [member up_direction] and [member floor_max_angle] are used to determine whether a surface is "floor" or not.

func (Instance) IsOnFloorOnly

func (self Instance) IsOnFloorOnly() bool

Returns [code]true[/code] if the body collided only with the floor on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. The [member up_direction] and [member floor_max_angle] are used to determine whether a surface is "floor" or not.

func (Instance) IsOnWall

func (self Instance) IsOnWall() bool

Returns [code]true[/code] if the body collided with a wall on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. The [member up_direction] and [member floor_max_angle] are used to determine whether a surface is "wall" or not.

func (Instance) IsOnWallOnly

func (self Instance) IsOnWallOnly() bool

Returns [code]true[/code] if the body collided only with a wall on the last call of [method move_and_slide]. Otherwise, returns [code]false[/code]. The [member up_direction] and [member floor_max_angle] are used to determine whether a surface is "wall" or not.

func (Instance) MaxSlides

func (self Instance) MaxSlides() int

func (Instance) MotionMode

func (self Instance) MotionMode() gdclass.CharacterBody3DMotionMode

func (Instance) MoveAndSlide

func (self Instance) MoveAndSlide() bool

Moves the body based on [member velocity]. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [CharacterBody3D] or [RigidBody3D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes. Modifies [member velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for more detailed information about collisions that occurred, use [method get_slide_collision]. When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions. Returns [code]true[/code] if the body collided, otherwise, returns [code]false[/code].

func (Instance) PlatformFloorLayers

func (self Instance) PlatformFloorLayers() int

func (Instance) PlatformOnLeave

func (self Instance) PlatformOnLeave() gdclass.CharacterBody3DPlatformOnLeave

func (Instance) PlatformWallLayers

func (self Instance) PlatformWallLayers() int

func (Instance) SafeMargin

func (self Instance) SafeMargin() Float.X

func (Instance) SetFloorBlockOnWall

func (self Instance) SetFloorBlockOnWall(value bool)

func (Instance) SetFloorConstantSpeed

func (self Instance) SetFloorConstantSpeed(value bool)

func (Instance) SetFloorMaxAngle

func (self Instance) SetFloorMaxAngle(value Float.X)

func (Instance) SetFloorSnapLength

func (self Instance) SetFloorSnapLength(value Float.X)

func (Instance) SetFloorStopOnSlope

func (self Instance) SetFloorStopOnSlope(value bool)

func (Instance) SetMaxSlides

func (self Instance) SetMaxSlides(value int)

func (Instance) SetMotionMode

func (self Instance) SetMotionMode(value gdclass.CharacterBody3DMotionMode)

func (Instance) SetPlatformFloorLayers

func (self Instance) SetPlatformFloorLayers(value int)

func (Instance) SetPlatformOnLeave

func (self Instance) SetPlatformOnLeave(value gdclass.CharacterBody3DPlatformOnLeave)

func (Instance) SetPlatformWallLayers

func (self Instance) SetPlatformWallLayers(value int)

func (Instance) SetSafeMargin

func (self Instance) SetSafeMargin(value Float.X)

func (Instance) SetSlideOnCeiling

func (self Instance) SetSlideOnCeiling(value bool)

func (Instance) SetUpDirection

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

func (Instance) SetVelocity

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

func (Instance) SetWallMinSlideAngle

func (self Instance) SetWallMinSlideAngle(value Float.X)

func (Instance) SlideOnCeiling

func (self Instance) SlideOnCeiling() bool

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) UpDirection

func (self Instance) UpDirection() Vector3.XYZ

func (Instance) Velocity

func (self Instance) Velocity() Vector3.XYZ

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) WallMinSlideAngle

func (self Instance) WallMinSlideAngle() Float.X

type MotionMode

type MotionMode = gdclass.CharacterBody3DMotionMode //gd:CharacterBody3D.MotionMode
const (
	/*Apply when notions of walls, ceiling and floor are relevant. In this mode the body motion will react to slopes (acceleration/slowdown). This mode is suitable for grounded games like platformers.*/
	MotionModeGrounded MotionMode = 0
	/*Apply when there is no notion of floor or ceiling. All collisions will be reported as [code]on_wall[/code]. In this mode, when you slide, the speed will always be constant. This mode is suitable for games without ground like space games.*/
	MotionModeFloating MotionMode = 1
)

type PlatformOnLeave

type PlatformOnLeave = gdclass.CharacterBody3DPlatformOnLeave //gd:CharacterBody3D.PlatformOnLeave
const (
	/*Add the last platform velocity to the [member velocity] when you leave a moving platform.*/
	PlatformOnLeaveAddVelocity PlatformOnLeave = 0
	/*Add the last platform velocity to the [member velocity] when you leave a moving platform, but any downward motion is ignored. It's useful to keep full jump height even when the platform is moving down.*/
	PlatformOnLeaveAddUpwardVelocity PlatformOnLeave = 1
	/*Do nothing when leaving a platform.*/
	PlatformOnLeaveDoNothing PlatformOnLeave = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL