English (Current) | 中文版
An advanced CharacterBody2D
/ CharacterBody3D
(WIPlan) that provides a bunch of new features to make your platform game development more easily.
A CharactformerBody2D
/ CharactformerBody3D
is an extended class of CharacterBody2D
/ CharacterBody3D
, which name comes from "character" and "platformer". Its name indicates that this class is designed for platformer games.
A charactformer body provide basic properties and methods for fast setting of platform game. For example, you can set its speed
, which is not a scale that describes the length of velocity in physics, but the velocity
transformed by a specific factor determined by speed_direction
, which is useful because you can ignore its gravity direction to fast set the speed even if the body is in a special-gravitified area. The following two pictures will help you better understand this property (Taking CharactformerBody2D
as an example here):
Yep, in a characfomer body, gravity are implemented without doing extra things. This means that only a slight call of moving function will the gravity be calculated and applied to the body. This is good because it makes the code simple and easy to understand.
You're right, and congratulations! You can accelerate a charactformer body by calling an accelerate_*()
method, and if you would like to be more Newton, the method apply_force()
and the property mass
and constant_force
are also a nice try, which is similar to ones in rigid body; however, they are always central, which means that all forces are applied at the central of the body.
By the way, why not try decelerate your body by get_floor_friction()
? This is a very useful method when you want a character body to slow down on the ground based on the friction of the floor. It helps you with cutting down complex boilerplate codes and make your code more well-polished.
A good question. When you want to move it, you should not call move_and_slide()
; instead, you should call move()
, which receives one parameter that controls if the gravity should be applied to the body.
Feeling depressed by default moving logic? Don't be down, you have a chance to override _move_logic()
virtual method to custom your own movement. From this point of view, you may find that the method move()
is a wrapper of _move_logic()
for meeting the requirement of naming regulation.
This does not mean that you cannot directly call _move_logic
, but for better comprehension, it's more recommended to call move()
.
Meanwhile, when a charactformer body collides with another body or tile that has collision, the signals - collided_wall
, collided_ceiling
, collided_floor
or collided_at_narrow_corner
, will be emitted accordingly, which allows you to listen to specific collision event and connect it to a custom action.
This is an extended class of CharactformerBody2D
/ CharactformerBody3D
, but this is preferred to be used for creating walking items or entities, such as enemies walking around and items with "legs and feet". Unlike CharactformerBody2D
/ CharactformerBody3D
, this class has a target_walking_speed
, which limits the speed that a automoving charactformer body should maintain. If the speed.x
does not equal to the value of the target_walking_speed
, the body will try accelerating or decelerating until its speed.x
reaches this value.
What's more, on call of move()
and execution of _move_logic()
, the automoving charactformer body can turn back on collision with a wall, without connecting collided_wall
signal to turn_h()
method, which would lead to potential problems.
- Godot 4.3 or later
- Windows x86 & x64, arm32 & arm64
- Linux x64, rv64, arm64
- iOS
- MacOS
- Android x86 & x64, arm32 & arm64
- Web wasm32