I gotcha covered there.
Assuming your player is a kinematic body, you should have access to the method test_move(Transform2D from, Vector2 rel_vec)
. Returns true if a collision occurs.
Which mean you will change this-
#tile_size is the size of the tilemap in pixels.
var new_position = position + motion_vector * tile_size
#Yes. I'm assuming you have a Tween node as a child.
$Tween.interpolate_property ( self, 'position', position, new_position, 0.6, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
#That last method's fifth property is how long it takes to go from one tile to the other in seconds.
$Tween.start()
moving = true
To this.
#tile_size is the size of the tilemap in pixels.
motion_vector *= tile_size
if not test_move(global_transform, motion_vector):
#Yes. I'm assuming you have a Tween node as a child.
$Tween.interpolate_property ( self, 'position', position, position+motion_vector, 0.6, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
#That last method's fifth property is how long it takes to go from one tile to the other in seconds.
$Tween.start()
moving = true
Notice that the new_position
variable was omitted and in the Tween's function replaced with position+motion_vector
.