Which method of differentiating accelerating and decelerating should I use?

This is a CharacterBody3D btw.

Should I use:

var moving = true if (ground_dir * speed).length() >= velocity.length() else false
speed = speed.move_toward(ground_dir * ground_speed, (ground_acel if moving else ground_decel) * delta)

Or:

var moving = true if dir.dot(get_real_velocity()) > 0 else false
speed = speed.move_toward(ground_dir * ground_speed, (ground_acel if moving else ground_decel) * delta)

dot could be negative, which seems like it’s no longer moving but moving_forward

2 Likes