im making my first attempt at a 3d godot game in the 4.5 vercion so i used a premade character controller wich is really good exept for one conflict that i can.t figure out how to fix it makes my character only take y knockback or more accurately resist a lot of x knockback (wich also means if i put enough for the x knockback to look good if you jump you end up in a new space program)
i use this code (the damage and dir come from the enemy, the pushback is a fixed variable wich is 8.0):
func hit(damage, dir):
hp -= damage
velocity = dir \* pushback
wich works but i didn.t know that since this code:
if can\_move:
var input\_dir := Input.get\_vector(input\_left, input\_right, input\_forward, input\_back)
var move\_dir := (transform.basis \* Vector3(input\_dir.x, 0, input\_dir.y)).normalized()
if move\_dir:
velocity.x = move\_dir.x \* move\_speed
velocity.z = move\_dir.z \* move\_speed
else:
velocity.x = move\_toward(velocity.x, 0, move\_speed)
velocity.z = move\_toward(velocity.z, 0, move\_speed)
else:
velocity.x = 0
velocity.y = 0
\# Use velocity to actually move
move\_and\_slide()
is causing a conflict that slows down ALL my x speed so knockback is affected as well i would rather keep this controller since its really good apart from this part and had some bad luck when i tried using others or making others so i wanted to ask for help on how to fix this issue
the full code: