Character will no longer move

Godot Version

4.4

Question

I was messing around in the animation player with positioning for the attack animation and now my character will no longer move. The animations play just fine. As far as I know it happened after giving the attack animation a position property track but ive since removed it with no luck. I also may have deleted the RESET animation around this time if that has anything to do with it?

heres the characterbody2D script

extends CharacterBody2D

@onready var speed = 1000.0
const jump_velocity = -3000

@onready var anim_tree : AnimationTree = $AnimationTree
@onready var stun_timer = $“…/Timer”
@onready var stun = false
@onready var timer_limit_movement = $“…/Timer”

#animations
func _ready() → void:
anim_tree.active = true

func _process(delta):
update_animation_parameters()
var direction = Vector2.ZERO

func _physics_process(delta: float) → void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta

# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
	velocity.y = jump_velocity

# Get the input direction: -1, 0, 1
direction = Input.get_axis("move_left", "move_right")

# apply character movement animation on direction input
if direction== 0:
	pass
#Apply movement
if direction:
	velocity.x = direction * speed
else:
	velocity.x = move_toward(velocity.x, 0, speed)

move_and_slide()

func update_animation_parameters():
if velocity.x == 0:
anim_tree[“parameters/conditions/idle”] = true
anim_tree[“parameters/conditions/is_moving”] = false
else:
anim_tree[“parameters/conditions/idle”] = false
anim_tree[“parameters/conditions/is_moving”] = true
if Input.is_action_just_pressed(“Test_attack_1”):
anim_tree[“parameters/conditions/attack”] = true
stun = true

	timer_limit_movement.start()
else:
	anim_tree["parameters/conditions/attack"] = false
	
anim_tree["parameters/walk 2/blend_position"] = direction

func _on_timer_timeout() → void:
stun = false

please help D: ive tried everything I can think of…

I can’t tell what is causing the player to not move by the script you posted. Can you print out (or check using the debugger) the velocity of the player? And the direction? Basically you should check the actual values of the movement variables.

W 0:00:00:900 _update_caches: AnimationMixer (at: player.tscn): ‘idle’, Value Track: ‘AnimatedSprite2D:animation’ blends String types. This is an experimental algorithm.
<C++ Source> scene/animation/animation_mixer.cpp:927 @ _update_caches()

W 0:00:00:892 _update_process_callback: Camera2D overridden to physics process mode due to use of physics interpolation.
<C++ Source> scene/2d/camera_2d.cpp:92 @ _update_process_callback()

W 0:00:00:366 The parameter “delta” is never used in the function “_process()”. If this is intended, prefix it with an underscore: “_delta”.
UNUSED_PARAMETER
fighting_game_player.gd:18
not sure how to do the second part you described. very new to coding

You need to use the print() function in order to have things show up in the output tab.

how do I use that to check velocity and direction?

i put print(velocity) and print(direction in _ready function. it came back (0.0, 0.0)
(0.0, 0.0) even while pressing movement keys. again, animations still working on movement keys pressed tho

You need to print in physics process, not ready, since ready only runs once.

okay, that shows it. they both seem to be working fine

I fixed it. i deleted and replaced everything and it was still doing it so I started pressing random things until… I needed to set motion mode of characterbody2D to grounded. not sure what that even means but it seems to have fixed it

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.