|
@@ -14,13 +14,6 @@ var motion = Vector2()
|
|
|
var target
|
|
|
onready var reaction_time = int(rand_range(20,60))
|
|
|
|
|
|
-func _ready():
|
|
|
-# var array = get_node('../../players').get_children()
|
|
|
- var array = get_tree().get_nodes_in_group('players')
|
|
|
- array.shuffle()
|
|
|
- if array.size() > 0:
|
|
|
- target = array[0]
|
|
|
-
|
|
|
var dir_buffer = 0
|
|
|
|
|
|
var tick = 0
|
|
@@ -33,5 +26,16 @@ func _physics_process(delta):
|
|
|
if target == null: return
|
|
|
dir_buffer += 1
|
|
|
if fmod(dir_buffer,reaction_time) == 0:
|
|
|
- if is_instance_valid(target): motion = (target.global_position - global_position).normalized() * speed
|
|
|
- position += motion*delta*tickrate
|
|
|
+ if is_instance_valid(target): motion.x = (target.global_position - global_position).normalized().x * speed
|
|
|
+ motion.y += 15
|
|
|
+ if motion.y > 0 and is_on_floor(): motion.y = 0
|
|
|
+ move_and_slide(motion*tickrate,Vector2.UP)
|
|
|
+
|
|
|
+func _on_Area2D_body_entered(body):
|
|
|
+ print(body)
|
|
|
+ if body.is_in_group('players'):
|
|
|
+ var array = get_tree().get_nodes_in_group('players')
|
|
|
+ array.shuffle()
|
|
|
+ if array.size() > 0:
|
|
|
+ target = array[0]
|
|
|
+ pass # Replace with function body.
|