why move speed didn't work?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatobanana

no matter how much move_speed value i put, this object still move at same speed. why, but if i remove normalize(), this object so fast

var  move_speed 
var move_dir = Vector2(0,0)

func _ready() -> void:
	rotation_degrees = 180

func _process(delta: float) -> void:
	move_dir.y += move_speed * delta
	global_rotation += 0.1

func move_loop():
	var motion = move_dir.normalized()
	var collide = move_and_collide(motion)
	if collide:

Can you try initializing move_speed to some value? Say, var move_speed = 2 instead of just var move_speed. Also delta in _process is very small initially and grows over time.

o3cat | 2020-03-04 13:43

Why do you have the line pass at the top? You do know you don’t need it.

Merlin1846 | 2020-03-04 16:28

:bust_in_silhouette: Reply From: Magso

normalized() basically sets the values between 0 and 1(Thanks Mariothedog) for example (20, 10).normalized() will become (1, 0.5) that’s why it’s slow. It needs to be multiplied by the speed again to behave normally. Also this posted code doesn’t warrant using normalized() as of now.

normalized() returns a vector with a length of 1 so Vector2(20, 10).normalized() returns Vector2(0.894427, 0.447214).

Mariothedog | 2020-03-04 16:08