distance changes dependent on physics speed?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wombatTurkey
:warning: 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:

enter image description here

And if the player has 1000 speed…:

enter image description here

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

:bust_in_silhouette: Reply From: keke

distance.length doesn’t become false in [your] if statement

I think the problem is that your eps is too small. Your following guy moves too far in one frame and overshoots, and then moves backwards and overshoots again ad infinitum. Try much, much larger eps values (like 50, 100) at first, and see what those look like. The units in godot are pixels which are really small :slight_smile:

Also, what is if new_pos.x: meant to do?

Aww good idea… new_pos.x is just the updated position from nodejs (testing some stuff). Thank you

wombatTurkey | 2017-03-28 05:51