Limited Ghost Aggression
This commit is contained in:
parent
c67eec8e05
commit
10e87b8d73
2 changed files with 11 additions and 3 deletions
|
|
@ -3,16 +3,25 @@ extends Area2D
|
|||
var speed = 100
|
||||
var damage = 1
|
||||
var player : CharacterBody2D
|
||||
var target : CharacterBody2D
|
||||
var current_knockback = Vector2.ZERO
|
||||
var knockback_weight = 800
|
||||
|
||||
var aggro_range = 900
|
||||
var chase_range = 1400
|
||||
|
||||
func _ready() -> void:
|
||||
player = get_parent().get_node("Player")
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var motion = -(position - player.position).normalized() * speed
|
||||
var dist = (position - player.position).length()
|
||||
self.position += motion * delta * min(1, dist/(motion.length()*delta))
|
||||
if(dist > chase_range):
|
||||
target = null
|
||||
elif(target == null and dist <= aggro_range):
|
||||
target = player
|
||||
if(target!=null):
|
||||
var motion = -(position - target.position).normalized() * speed
|
||||
self.position += motion * delta * min(1, dist/(motion.length()*delta))
|
||||
|
||||
self.position += earth_aligner.global_from_local(current_knockback) * delta
|
||||
current_knockback = current_knockback/pow(1.3, 60*delta)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://cxo6bq26huau7"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cmaovvr15b3qk" path="res://player/player.tscn" id="2_1bvp3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://vgxh2xdevat7" path="res://world/earth.gd" id="2_lquwl"]
|
||||
[ext_resource type="PackedScene" uid="uid://chu67ci7sl488" path="res://enemies/ghost.tscn" id="3_h2yge"]
|
||||
[ext_resource type="PackedScene" uid="uid://jjoyj1ldafkf" path="res://world/earth.tscn" id="3_lquwl"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue