Currently I am using the following script for a tile size of 16 and a walk speed of 4.
percent_moved_to_next_tile += walk_speed * delta
if percent_moved_to_next_tile >= 1.0:
percent_moved_to_next_tile = 0.0
is_moving = false
else:
position = initial_posistion + (Tile_Size * input_direction * percent_moved_to_next_tile)
If I change the walk speed to anything other than 4, its possible to end up between tiles due to "percent_moved_to_next_tile". I was wondering if anyone had any ideas for a smooth transform from initial position to end position. I think Interpolation would work Im just not sure how to go about it. In unity this would be as simple as:
isMoving = true
while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon)
{
transform.position = Vector3.MoveTowards(transform.position, targetPos, movementSpeed * Time.delta)
}
transform.position = targetPos;
isMoving = false;
Walk speed 4: move 1 tile.
Walk speed 8: move 1 tile