VoxelBoxMover

Inherits: RefCounted

Description:

Utility class allowing to reproduce simple move-and-slide logic using only voxel AABBs, similar to Minecraft physics. This class may only be used with blocky voxels.

Store an instance of it within a member variable of your script, and use it within Node._process or Node._physics_process (it works wherever you like).

var motion = Vector3(0, 0, -10 * delta) # Move forward
motion = _box_mover.get_motion(get_translation(), motion, aabb, terrain_node)
global_translate(motion)

Methods:

Return Signature
int get_collision_mask ( ) const
float get_max_step_height ( ) const
Vector3 get_motion ( Vector3 pos, Vector3 motion, AABB aabb, Node terrain )
bool has_stepped_up ( ) const
bool is_step_climbing_enabled ( ) const
void set_collision_mask ( int mask )
void set_max_step_height ( float height )
void set_step_climbing_enabled ( bool enabled )

Method Descriptions

int get_collision_mask( )

Gets the collision mask used to detect collidable voxels.

This collision mask is specific to this collision system, and is defined in VoxelBlockyModel.collision_mask.

float get_max_step_height( )

(This method has no documentation)

Vector3 get_motion( Vector3 pos, Vector3 motion, AABB aabb, Node terrain )

Given a motion vector, returns a modified vector telling you by how much to move your character. This is similar to KinematicBody.move_and_slide, except you have to apply the movement.

bool has_stepped_up( )

When step climbing is enabled, tells when the last call to VoxelBoxMover.get_motion caused climbing to occur.

Climbing modifies the motion vector upwards so that the body is snapped on top of the step. This can have implications in character controller code, such as considering the character to be on the floor instead of having jumped.

bool is_step_climbing_enabled( )

Tells if step climbing is enabled.

void set_collision_mask( int mask )

Sets the collision mask used to detect collidable voxels.

Only voxels sharing at least one bit between the masks will be detected.

This collision mask is specific to this collision system, and is defined in VoxelBlockyModel.collision_mask.

void set_max_step_height( float height )

Sets the maximum height that can be climbed like "stairs".

void set_step_climbing_enabled( bool enabled )

When enabled, VoxelBoxMover.get_motion will attempt to climb up small steps. This allows to implement Minecraft-like stairs.

Generated on Apr 06, 2024