#Weird math stuff(solved)

1 messages · Page 1 of 1 (latest)

dawn parcel
#

I am still very new to odin, as in installed it yesterday, and i am rewriting code that worked in c++
it just seems werid that the velocity is reporting back as nonzero, despite the lack of movement, I could just be creating the fuctions wrong, I had already done the update fuction as a pass by reference and was experiencing the same problem

#

visually what is going on here

#

there is also a period where the difference in position exceeds velocity

#

Object starts at the center

reef saddle
#

Sorry, need for coffee

dawn parcel
#

and is given a velocity of 0.5

#

No worries, every question is welcome

reef saddle
#

You check the collision every frame, right?

dawn parcel
#

Yup

reef saddle
#

In if block, put na.pos a bit further from the edge

#

Like max_x - a.rad - 0.5 or smth

dawn parcel
#

i had done max_x - a.rad - 2

#

still gets stuck

#

Again its not repeadedly going into that if block, because if it did, it would be printing out right edge every frame

#

it also doesn't get stuck if the x component of the velocity is set to 1

#

and if i set velocity of x to 0.49 it gets stuck before the edge

reef saddle
#

Because it rounds to 0

dawn parcel
#

when i set v to 0.51 again no problems

reef saddle
#

It doesn't get stuck at all?

dawn parcel
#

nope

#

doesn't get stuck at v = 0.501 either

reef saddle
#

Does it get stuck at the edge when it's 0.51?

dawn parcel
#

nope

reef saddle
#

I guess it's a bug then

#

Try using f32 instead

dawn parcel
#

There is also a region of the screen where the distance gained it double expected

dawn parcel
#

I guess It fell into a werid pocket of the f16 data range

reef saddle
#

Try using math.round() function

dawn parcel
#

I mean it fits with some of the other behavior where the gained position was double of expect, during the floating point addition operation, it just shifted out the additional bits

reef saddle
#

na.pos += math.round(na.vel)

dawn parcel
#

Weird math stuff (Solved)

dawn parcel
#

Weird math stuff