frab moves!
This commit is contained in:
parent
12cce7f4ae
commit
f933ad85f1
4 changed files with 57 additions and 18 deletions
19
objects/enemies/frab/frab.gd
Normal file
19
objects/enemies/frab/frab.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
extends Enemy
|
||||||
|
|
||||||
|
|
||||||
|
@export var wander_range: float
|
||||||
|
@export var max_home_distance: float
|
||||||
|
|
||||||
|
|
||||||
|
@onready var _target_pos: Vector2 = global_position
|
||||||
|
@onready var _home_pos: Vector2 = global_position
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if (global_position - _target_pos).length() < 2.0:
|
||||||
|
_target_pos = Vector2.INF
|
||||||
|
while _home_pos.distance_to(_target_pos) > max_home_distance:
|
||||||
|
_target_pos = global_position + (Vector2.RIGHT * randf() * wander_range).rotated(randf() * TAU)
|
||||||
|
#global_position = global_position.move_toward(_target_pos, move_speed * delta)
|
||||||
|
global_position += (global_position.direction_to(_target_pos)) * move_speed * delta
|
||||||
|
print(_target_pos)
|
||||||
1
objects/enemies/frab/frab.gd.uid
Normal file
1
objects/enemies/frab/frab.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://botgy5lnepotc
|
||||||
|
|
@ -1,7 +1,22 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://o273v7ll6m0h"]
|
[gd_scene load_steps=6 format=3 uid="uid://o273v7ll6m0h"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://orvwbw12311i" path="res://assets/graphics/frab.png" id="1_px4ud"]
|
[ext_resource type="Texture2D" uid="uid://orvwbw12311i" path="res://assets/graphics/frab.png" id="1_px4ud"]
|
||||||
[ext_resource type="Script" uid="uid://d2k5tlvpqokqr" path="res://objects/enemies/enemy.gd" id="1_r8e57"]
|
[ext_resource type="Script" uid="uid://botgy5lnepotc" path="res://objects/enemies/frab/frab.gd" id="1_r8e57"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_lvd4h"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:flip_h")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [false]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_r8e57"]
|
[sub_resource type="Animation" id="Animation_r8e57"]
|
||||||
resource_name = "flab"
|
resource_name = "flab"
|
||||||
|
|
@ -21,21 +36,6 @@ tracks/0/keys = {
|
||||||
"values": [false, true]
|
"values": [false, true]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_lvd4h"]
|
|
||||||
length = 0.001
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("Sprite2D:flip_h")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 1,
|
|
||||||
"values": [false]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qb3yn"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_qb3yn"]
|
||||||
_data = {
|
_data = {
|
||||||
&"RESET": SubResource("Animation_lvd4h"),
|
&"RESET": SubResource("Animation_lvd4h"),
|
||||||
|
|
@ -44,6 +44,9 @@ _data = {
|
||||||
|
|
||||||
[node name="Frab" type="Node2D"]
|
[node name="Frab" type="Node2D"]
|
||||||
script = ExtResource("1_r8e57")
|
script = ExtResource("1_r8e57")
|
||||||
|
wander_range = 100.0
|
||||||
|
max_home_distance = 200.0
|
||||||
|
move_speed = 100.0
|
||||||
metadata/_custom_type_script = "uid://d2k5tlvpqokqr"
|
metadata/_custom_type_script = "uid://d2k5tlvpqokqr"
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://bnjujh22nqr4a"]
|
[gd_scene load_steps=7 format=3 uid="uid://bnjujh22nqr4a"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://diymfwm64gae8" path="res://icon.svg" id="1_uhqqe"]
|
[ext_resource type="Texture2D" uid="uid://diymfwm64gae8" path="res://icon.svg" id="1_uhqqe"]
|
||||||
[ext_resource type="PackedScene" uid="uid://djpowg53xsgux" path="res://objects/player/player.tscn" id="2_ia1lp"]
|
[ext_resource type="PackedScene" uid="uid://djpowg53xsgux" path="res://objects/player/player.tscn" id="2_ia1lp"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://o273v7ll6m0h" path="res://objects/enemies/frab/frab.tscn" id="3_7cbxl"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cbjv7fecdoet5" path="res://objects/enemies/belough/belough.tscn" id="4_8pr8v"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cyn42vceeg8n3" path="res://objects/enemies/kith/kith.tscn" id="5_buypi"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dfrj00ro4rm5l" path="res://objects/enemies/spitting_fiend/spitting_fiend.tscn" id="6_njel3"]
|
||||||
|
|
||||||
[node name="TestScene" type="Node2D"]
|
[node name="TestScene" type="Node2D"]
|
||||||
|
|
||||||
|
|
@ -15,4 +19,16 @@ texture = ExtResource("1_uhqqe")
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("2_ia1lp")]
|
[node name="Player" parent="." instance=ExtResource("2_ia1lp")]
|
||||||
position = Vector2(115, 93)
|
position = Vector2(115, 93)
|
||||||
walk_speed = 100.0
|
|
||||||
|
[node name="Frab" parent="." instance=ExtResource("3_7cbxl")]
|
||||||
|
position = Vector2(170, 129)
|
||||||
|
max_home_distance = 100.0
|
||||||
|
|
||||||
|
[node name="Belough" parent="." instance=ExtResource("4_8pr8v")]
|
||||||
|
position = Vector2(67, 175)
|
||||||
|
|
||||||
|
[node name="Kith" parent="." instance=ExtResource("5_buypi")]
|
||||||
|
position = Vector2(174, 219)
|
||||||
|
|
||||||
|
[node name="SpittingFiend" parent="." instance=ExtResource("6_njel3")]
|
||||||
|
position = Vector2(280, 175)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue