The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hello, I'm new to Godot Engine and also this Q&A.

I'm studying 3D game development and made a simple FPS controller with the help of YouTube tutorials and Godot documentation, but I'm still having a problem:

I use a Vector3 to determine the direction of the player like that:

if Input.is_action_pressed("move_forward"):
    direction -= transform.basis.z
if Input.is_action_pressed("move_backward"):
    direction += transform.basis.z
if Input.is_action_pressed("move_left"):
    direction -= transform.basis.x
if Input.is_action_pressed("move_right"):
    direction += transform.basis.x

Some tutorials said I needed to use direction.normalized() to prevent the player from moving faster when pressing different movement keys (like forward + left for example) but the problem is that direction.normalized() don't make any difference to my game. I tested it:

print("Before normalized: " , direction)
print("After normalized: " , direction)

Both print() commands give the same direction vector, meaning that direction.normalized() didn't change any value. Is there a better way to prevent the player from moving faster while pressing different movement keys?

in Engine by (94 points)

1 Answer

+1 vote
Best answer

That's because you're not using the result of normalized()

direction = direction.normalized()
by (22,191 points)
selected by

Thanks! It helped a lot!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.