Add Player Movement animation to the target cell
This commit is contained in:
parent
24cc1b8f04
commit
263d323d58
@ -1,3 +1,17 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
export var starting_pos : Vector2 = Vector2.ZERO
|
export var map_position : Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
var target_position : Vector2 = Vector2.ZERO
|
||||||
|
var moving : bool = false
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
|
||||||
|
# If the 2 positions are close enough, then not moving
|
||||||
|
moving = false if target_position.round() == position.round() else true
|
||||||
|
|
||||||
|
if not moving: return
|
||||||
|
|
||||||
|
#TODO: Replace with tween magic
|
||||||
|
position += (target_position - position)/2.5
|
||||||
|
@ -25,5 +25,11 @@ func _physics_process(delta):
|
|||||||
if movement_queue.find(Vector2.ZERO) != -1:
|
if movement_queue.find(Vector2.ZERO) != -1:
|
||||||
movement_queue.remove(movement_queue.find(Vector2.ZERO))
|
movement_queue.remove(movement_queue.find(Vector2.ZERO))
|
||||||
|
|
||||||
|
if len(movement_queue) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
#move the character once space in the queue if not moving
|
||||||
|
if not $Player.moving:
|
||||||
|
$Player.map_position += movement_queue.pop_front()
|
||||||
|
$Player.target_position = $TileMap.map_to_world($Player.map_position)
|
||||||
|
$Player.target_position += $TileMap.cell_size/2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user