How to get a zero

Blitz3D Forums/Blitz3D Programming/How to get a zero

xmlspy(Posted 2007) [#1]
What's the best way to obtain a zero value on PLAYER_CMOVESPEED#
It starts doing this 1.-e1234 things after a while.

Should floats just be avoided?




H&K(Posted 2007) [#2]
If (PLAYER_CMOVESPEED#+1) <> 1 Then
    MoveEntity PLAYER_MESH, 0, 0, PLAYER_CMOVESPEED#
Else
    PLAYER_CMOVESPEED# = 0
EndIf
This is just one of those things, rounding error will make PLAYER_CMOVESPEED sort of wobble even when you think it should be 0. All the code Ive printed does, is make sure that if PLAYER_CMOVESPEED is sort of 0 to 6 decimels then it will be treated as 0, and set to 0

Another solution would be
if Mod (PLAYER_CMOVESPEED) < 0.0001 then....
But I dont know B3D syntax, so you may have to mess with it.

(Edit, (Ignore this comment) its really 6.22 Decimels, but dont tell anyone hahahahahahaha)

Edit: On a seperate issue the Player_CmoveSpeed should be part of a Vector called Velocity. Cos Really Speed can never be negative. And The Accel should always be added to it, that is both should have a positive value and a direction. But thats just me being pedantic. So dont take any real notice of this.



Stevie G(Posted 2007) [#3]
Something like this? Dodgy key choice btw ;)