Does Input.get_vector() auto-normalize the vector?

Godot Version

4.2.1

Question

Hello! I was trying to do a 2D movement using Input.get_vector() to get the Input and I thougth it was then necessary to normalize the vector, but it seems like it’s already normalized! This is my code (simplified version): `

var direction = Input.get_vector(“left”,“right”,“up”,“down”)

velocity = direction * 100

move_and_slide()`

Does anybody know if it’s already normalized? Thanks.

Yes it is normalized, the docs say so in a not-mathy-way

The vector has its length limited to 1 and has a circular deadzone, which is useful for using vector input as movement.

1 Like

Technically it’s not normalized. Normalized vectors always have a length of exactly 1. The input vector can have any length in the range of 0 to 1 (if using an analog joystick), but never more than 1.

4 Likes

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