You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Gridmap/scripts/Instance3D.gd

30 lines
813 B

extends CharacterBody3D
const SPEED = 10.0
var id = -1
var inputs = {"ui_right": Vector3.RIGHT,
"ui_left": Vector3.LEFT,
"ui_up": Vector3.FORWARD,
"ui_down": Vector3.BACK}
func connect_to_world(id):
var world_entity = Global.world.entities[id]
world_entity.moving.connect(_on_entity_moving)
pass
#
#func _unhandled_input(event):
# for dir in inputs.keys():
# if event.is_action_pressed(dir):
# var new_position = position + inputs[dir]
# move(new_position)
#
#func move(new_position):
# var tween = get_tree().create_tween()
# tween.tween_property(self, "position", new_position, 1/SPEED).set_trans(Tween.TRANS_SINE)
func _on_entity_moving(new_position):
var tween = get_tree().create_tween()
tween.tween_property(self, "position", new_position, 1/SPEED).set_trans(Tween.TRANS_SINE)
pass