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

20 lines
646 B

extends CharacterBody3D
var id = -1
@onready var ray = $RayCast3D
func _process(delta):
var height = ray.get_collision_point().y
if position.y != height:
var tween = get_tree().create_tween()
tween.tween_property(self, "position:y", height, 0.1)
func connect_to_world(id):
var world_entity = Global.world.entities[id]
world_entity.moving.connect(_on_entity_moving)
func _on_entity_moving(new_position, speed):
var x_tween = get_tree().create_tween()
var z_tween = get_tree().create_tween()
x_tween.tween_property(self, "position:x", new_position.x, 1.0/speed)
z_tween.tween_property(self, "position:z", new_position.y, 1.0/speed)