Hsif/Scripts/Net.gd

43 lines
786 B
GDScript

extends Area2D
var fish = CharacterBody2D
@export
var target = 0
@export
var ai = 0
@export
var speed = 1
# Called when the node enters the scene tree for the first time.
func _ready():
fish = get_tree().get_first_node_in_group("Fish") #fish
match ai:
#set position
0:
position = Vector2(-1857, target)
#fish position
1:
position = Vector2(-1857, fish.position.y)
#predict position
2: pass
if position.y > 317:
position.y = 317
if position.y < -192:
position.y = -192
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
goFish()
func goFish():
position.x = position.x + speed
if position.x > 1494:
queue_free()
func _on_body_entered(body):
if body.is_in_group("Fish"):
fish.hurt = true