In Godot 4.1, I have a third-person character controller. It's a CharacterBody3D with a child Node3D called PlayerContent. The visual components of the character (model, etc.) are all children of PlayerContent. To move the character, I've created a Vector3 called direction that gets the joystick input:
func get_input_direction(): direction.x = Input.get_axis("move_left", "move_right") direction.z = Input.get_axis("move_forward", "move_backward")
The player can be Z-targeting or moving freely. In the case of moving freely, I rotate PlayerContent to match the direction of movement (giving the illusion that the character is turning, even though the CharacterBody3D isn't). In the case of Z-targeting, I rotate PlayerContent towards the target.
In order to make direction relative to the camera, I rotate direction by the camera's rotation.
func player_direction_to_camera(): get_input_direction() direction = direction.rotated(Vector3.UP, camera.rotation.y)
Lastly, I set the velocity variable that move_and_slide() uses to equal direction.
I'd like to be able to tell which way direction is compared to the value the Vector2 is being rotated by. For example, if the player is moving left (relative to PlayerContent's rotation), I'd like to be able to specify the dodge type to be left_dodge (or something to that effect.) Or forward_dodge, or backflip, or anything like that.
I'm not very good at vector math, so I'd appreciate some help with this.