Vector3 not being set correctly

Hi, so ive run into this problem and honestly don’t have any idea whats going wrong. would love some advice on what might be happening and where I can look for answers.

so I’m trying to slow the zombie’s walk speed when turning. So I want to compare the look vectors in a loop with the previous look vector and see if is within a certain tolerance for being the “same” direction.

in my code I don’t understand why line 13 and 14 contradict each other

3 Likes

I’m pretty sure it’s because Vector3 values purposely don’t represent super small numbers (probably past the hundredths is where there’s no more representation)

1 Like

i tried this idk the fix but the problem isnot in your code because

local vec3 = Vector3.new(0,1.85,0)

print(vec3)

image
i donot think that there is a fix for this bc that is how Floating Point work its abit inaccurate

2 Likes

okay, stupid i didn’t test this but i didn’t need to have it accurate, I just removed the divide and kept them as integers and it works properly now. Still don’t understand the problem tho.

3 Likes

that happend because that is how floating-point numbers work and how computers handle them and i think that roblox do math or smt with the input in vector3 that is why they lose precision
but amnot completely if roblox does that

floating point is a 32(single precision) or 64-bit (double precision) and its a datatype that can have decimal numbers you can see the vid on the top to know why that happens

and there is no way to prevent that

3 Likes

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