How to normalize vec3?

when im pressing w + d, w + a … etc - my speed is 4.2 when actually it should be 3

i can normalize this myself, but is there a function to do this

Of course, I know two options.

from panda3d.core import Vec3

vector_1 = Vec3(34, 4, 12)
vector_1.normalize()
print(vector_1)

vector_2 = Vec3(34, 4, 12)
vector_normalize = vector_2.normalized()
print(vector_normalize)

You can find more details here. You need to remember that Vec3 is an alias in python. And in C++ it will be LVector3f.

https://docs.panda3d.org/1.10/cpp/reference/panda3d.core.Vec3

1 Like