This repository has been archived on 2022-03-31. You can view files and clone it, but cannot push or open issues or pull requests.
Tyra/scripts/Ennemi.gd

21 lines
541 B
GDScript3
Raw Normal View History

2021-04-03 23:47:20 +02:00
extends KinematicBody2D
var deplacement = Vector2()
2021-04-07 19:41:25 +02:00
var ecart = 260
2021-04-03 23:47:20 +02:00
func _ready():
pass
2021-04-07 18:15:55 +02:00
func _physics_process(_delta):
2021-04-03 23:47:20 +02:00
var Joueur = get_parent().get_node("Joueur") # récupère le joueur
2021-04-07 19:41:25 +02:00
if (Joueur.position.x + ecart) > position.x and (Joueur.position.y + ecart) > position.y:
2021-04-07 19:48:53 +02:00
position += (Joueur.position - position) / 50 # rapidité
2021-04-07 19:41:25 +02:00
look_at(Joueur.position) # regarde le joueur
2021-04-03 23:47:20 +02:00
2021-04-07 18:15:55 +02:00
move_and_collide(deplacement) # empeche la superposition des ennemis
2021-04-03 23:47:20 +02:00
func _on_Area2D_body_entered(body):
if "Balle" in body.name:
queue_free()