I’m having this weird problem holding me back on handling collision:
when my object collide, i undo it’s movement (subtract velocities from position, solving the collision) then i reverse its velocity, a pretty basic collision handling for bouncing…, problem is that sometimes the object wont get back to it’s original position (before adding it’s velocities)
here is a basic check i did, which returned a weird response
if (tag == "player") trace("px: " + x);
x += vx;
y += vy;
x -= vx;
y -= vy;
if (tag == "player") trace("--->dx: " + x);
output:
--->dx: 200
px: 200
--->dx: 200
px: 200
--->dx: 200
px: 200
--->dx: 200
px: 200
--->dx: 199.95000000000002
px: 199.95000000000002
--->dx: 199.9
px: 199.9
--->dx: 199.85000000000002
px: 199.85000000000002
--->dx: 199.8
px: 199.8
--->dx: 199.75
px: 199.75
--->dx: 199.70000000000002
px: 199.70000000000002
--->dx: 199.65
px: 199.65
--->dx: 199.60000000000002
px: 199.60000000000002
--->dx: 199.55
px: 199.55
--->dx: 199.5
px: 199.5
--->dx: 199.45000000000002
px: 199.45000000000002
--->dx: 199.4
px: 199.4
--->dx: 199.35000000000002
px: 199.35000000000002
--->dx: 199.3
px: 199.3
--->dx: 199.25
px: 199.25
--->dx: 199.20000000000002
px: 199.20000000000002
--->dx: 199.15
px: 199.15
--->dx: 199.10000000000002
px: 199.10000000000002
--->dx: 199.05
px: 199.05
--->dx: 199
the object’s position value is reduced by .05 every loop when i add and subtract it’s velocities (same value)
looks like some problem with number precision, any ideas on how to solve this?