You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
An accurate velocity.
What is the issue? Include screenshots / videos if possible!
Inaccurate velocity, the velocity goes wack when I hit a wall.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried spawning a part that goes with the player instead of relying on the rootPart, yielded the same result.
print((root_part.AssemblyLinearVelocity*Vector3.new(1, 0, 1)).Magnitude)
this is quite literally all the code there is
Behaving in what way? I don’t understand.
Let me provide a video my bad, I thought I did:
As you can see in the video, the velocity works as intended prior to bumping into the wall. After bumping into it though, things get weird for some reason and I don’t know what’s causing this? I have replicated this issue on another blank baseplate and same result. When it works as intended, the value drops to zero, as it should. When it works not as intended, I don’t even know how to describe it.
You should have described the issue is non zero, weird numbers.
The issue is just floating point errors those 1e-7 is equal to 0.0000001 which is basically 0, use math.round up to a certain decimal point to get a nicer number
function roundNumber(num, numDecimalPlaces)
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
print(roundNumber(4.6787673219385, 1)) --prints 4.7
print(roundNumber(4.6787673219385, 2)) --prints 4.68
print(roundNumber(4.6787673219385, 3)) --prints 4.679
Right, my bad, it was 12 am when I wrote this couldn’t really see well. Thanks for answering, I think this is the solution.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.