- Edited
I'm just looking to hear some opinions on the best way to handle moving a character in different ways based on the character's situation.
The issue is that when a character is in a different state (i.e. climbing as opposed to walking normally), you want to handle the way input is processed to move the character (i.e. parallel to the surface as opposed to relative to the camera). Generally speaking, the standard approach would be to have flags set when the player enters a certain movement state and check for it when determining how to move the character. These different movement forms could be separated out into individual functions for readability, or handled with branching if statements in a single function. Examples are provided below:
Separate Functions:
func _process(delta)
if (climbing)
_move_climbing(delta)
else
_move_normal(delta)
func _move_climbing(delta)
# Code to move character while climbing
func _move_normal(delta)
# Code to move character normally (i.e. relative to camera)
Branching if Statements:
func _process(delta)
var movement = Vector3()
if (climbing)
# Calculate movement for climbing
else
# Calculate movement for normal walking
move_and_slide(movement)
Just wondering if anyone else has made a character controller that required similar methods and if there's any better way to go about moving a character under different conditions.