-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharcher_script.gd
More file actions
39 lines (30 loc) · 937 Bytes
/
archer_script.gd
File metadata and controls
39 lines (30 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
extends KinematicBody2D
onready var Master = get_node(".")
onready var animation_player = get_parent().get_node("AnimationPlayer")
onready var reached = false
export var SPEED = 150
var RNG = RandomNumberGenerator.new()
onready var RNG_NUM
func _ready():
RNG.randomize()
RNG_NUM = (RNG.randi_range( 1, 2 ))
if RNG_NUM == 1:
RNG_NUM = WorldPOS.position_1
else:
RNG_NUM = WorldPOS.position_2
Master.position = Vector2(1200, 300)
animation_player.play("walking")
func _physics_process(delta):
var direction
if reached == false:
if RNG_NUM.distance_to(Master.position) > 10:
direction = RNG_NUM - Master.position
direction = direction.normalized() * SPEED
move_and_slide(direction, Vector2())
else:
reached = true
Master.position = WorldPOS.position_3
Master.z_index = 5
direction = Master.position
animation_player.play("shoot_down")
get_parent().get_node("projectile/Timer").start()