Брождение npc
This commit is contained in:
parent
1a29a449b0
commit
81054b3572
@ -3,6 +3,9 @@ extends Node2D
|
||||
|
||||
var id_path: Array[Vector2i]
|
||||
|
||||
func is_walking() -> bool:
|
||||
return not id_path.is_empty()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
|
@ -13,10 +13,12 @@ func add_npc(pos: Vector2i):
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
add_npc(Vector2i(16, 8))
|
||||
add_npc(Vector2i(40, 32))
|
||||
set_npc_target(npcs[0], Vector2i(24, 48))
|
||||
set_npc_target(npcs[1], Vector2i(24, 49))
|
||||
randomize()
|
||||
add_npc(Vector2i(11, 8))
|
||||
add_npc(Vector2i(9, 9))
|
||||
add_npc(Vector2i(12, 11))
|
||||
|
||||
|
||||
|
||||
|
||||
func set_npc_target(npc: NPC, target: Vector2i):
|
||||
@ -29,5 +31,8 @@ func set_npc_target(npc: NPC, target: Vector2i):
|
||||
npc.id_path = id_path
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
func _physics_process(delta: float) -> void:
|
||||
for npc in npcs:
|
||||
if not npc.is_walking():
|
||||
set_npc_target(npc, Vector2i(randi()%64,randi()%64))
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user