Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | wombatTurkey | |
Old Version | Published before Godot 3 was released. |
Example:
var eps = 1.5
if new_pos.x:
var distance = new_pos - get_pos()
var direction = distance.normalized() # direction of movement
print(distance.length())
if distance.length() > eps:
set_linear_velocity(direction*player_speed)
else:
set_linear_velocity(Vector2(0, 0)) # close enough - stop moving
Okay, so this works great if the player_speed
is like 100 or so. If it’s anything higher than that, the distance.length
doesn’t become false in my if statement (sometimes)
Weird… So, with 100 player speed:
And if the player has 1000 speed…:
The distance.length atlernates between
5.366675
and
12.077275
…
It never gets below my eps
of 1.5?
e: Btw, this is in _integrate_forces