Imported into Godot 4.3
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
extends KinematicBody2D
|
||||
extends CharacterBody2D
|
||||
|
||||
const EnemyDeathEffect = preload("res://Effects/EnemyDeathEffect.tscn")
|
||||
|
||||
export var ACCELERATION = 300
|
||||
export var MAX_SPEED = 50
|
||||
export var FRICTION = 200
|
||||
export var WANDER_TARGET_RANGE = 4
|
||||
@export var ACCELERATION = 300
|
||||
@export var MAX_SPEED = 50
|
||||
@export var FRICTION = 200
|
||||
@export var WANDER_TARGET_RANGE = 4
|
||||
|
||||
enum {
|
||||
IDLE,
|
||||
@ -18,20 +18,22 @@ var velocity = Vector2.ZERO
|
||||
|
||||
var state = IDLE
|
||||
|
||||
onready var sprite = $AnimatedSprite
|
||||
onready var stats = $Stats
|
||||
onready var playerDetectionZone = $PlayerDetectionZone
|
||||
onready var hurtbox = $Hurtbox
|
||||
onready var softCollision = $SoftCollision
|
||||
onready var wanderController = $WanderController
|
||||
onready var animationPlayer = $AnimationPlayer
|
||||
@onready var sprite = $AnimatedSprite2D
|
||||
@onready var stats = $Stats
|
||||
@onready var playerDetectionZone = $PlayerDetectionZone
|
||||
@onready var hurtbox = $Hurtbox
|
||||
@onready var softCollision = $SoftCollision
|
||||
@onready var wanderController = $WanderController
|
||||
@onready var animationPlayer = $AnimationPlayer
|
||||
|
||||
func _ready():
|
||||
state = pick_new_state([IDLE,WANDER])
|
||||
|
||||
func _physics_process(delta):
|
||||
knockback = knockback.move_toward(Vector2.ZERO, 200 * delta)
|
||||
knockback = move_and_slide(knockback)
|
||||
set_velocity(knockback)
|
||||
move_and_slide()
|
||||
knockback = velocity
|
||||
|
||||
match state:
|
||||
IDLE:
|
||||
@ -58,7 +60,9 @@ func _physics_process(delta):
|
||||
|
||||
if softCollision.is_colliding():
|
||||
velocity += softCollision.get_push_vector() * delta * 400
|
||||
velocity = move_and_slide(velocity)
|
||||
set_velocity(velocity)
|
||||
move_and_slide()
|
||||
velocity = velocity
|
||||
|
||||
func accelerate_towards_point(point,delta):
|
||||
var direction = global_position.direction_to(point)
|
||||
@ -67,7 +71,7 @@ func accelerate_towards_point(point,delta):
|
||||
|
||||
func update_wander():
|
||||
state = pick_new_state([IDLE, WANDER])
|
||||
wanderController.start_wander_timer(rand_range(1,3))
|
||||
wanderController.start_wander_timer(randf_range(1,3))
|
||||
|
||||
func seek_player():
|
||||
if playerDetectionZone.can_see_player():
|
||||
@ -87,7 +91,7 @@ func _on_Hurtbox_area_entered(area):
|
||||
|
||||
func _on_Stats_no_health():
|
||||
queue_free()
|
||||
var enemyDeathEffect = EnemyDeathEffect.instance()
|
||||
var enemyDeathEffect = EnemyDeathEffect.instantiate()
|
||||
get_parent().add_child(enemyDeathEffect)
|
||||
enemyDeathEffect.global_position = global_position
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/Bat.png-38405154cd5b8ff1c5e2fcf1cef1c3e6.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://sia0qera1a0e"
|
||||
path="res://.godot/imported/Bat.png-38405154cd5b8ff1c5e2fcf1cef1c3e6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@ -10,26 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://Enemies/Bat.png"
|
||||
dest_files=[ "res://.import/Bat.png-38405154cd5b8ff1c5e2fcf1cef1c3e6.stex" ]
|
||||
dest_files=["res://.godot/imported/Bat.png-38405154cd5b8ff1c5e2fcf1cef1c3e6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=26 format=2]
|
||||
|
||||
[ext_resource path="res://Enemies/Bat.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Shadows/SmallShadow.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Enemies/Bat.png" type="Texture2D" id=1]
|
||||
[ext_resource path="res://Shadows/SmallShadow.png" type="Texture2D" id=2]
|
||||
[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://Enemies/Bat.gd" type="Script" id=4]
|
||||
[ext_resource path="res://Stats.tscn" type="PackedScene" id=5]
|
||||
@ -63,14 +63,14 @@ radius = 5.0
|
||||
[sub_resource type="Animation" id=13]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("AnimatedSprite:material:shader_param/active")
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:material:shader_param/active")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"update": 0,
|
||||
"values": [ false ]
|
||||
}
|
||||
@ -80,14 +80,14 @@ resource_name = "Start"
|
||||
length = 0.2
|
||||
loop = true
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("AnimatedSprite:material:shader_param/active")
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:material:shader_param/active")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"times": PackedFloat32Array( 0, 0.1 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
}
|
||||
@ -96,23 +96,23 @@ tracks/0/keys = {
|
||||
resource_name = "Stop"
|
||||
length = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("AnimatedSprite:material:shader_param/active")
|
||||
tracks/0/path = NodePath("AnimatedSprite2D:material:shader_param/active")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"times": PackedFloat32Array( 0 ),
|
||||
"transitions": PackedFloat32Array( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
|
||||
[node name="Bat" type="KinematicBody2D"]
|
||||
[node name="Bat" type="CharacterBody2D"]
|
||||
collision_layer = 16
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
material = SubResource( 12 )
|
||||
frames = SubResource( 6 )
|
||||
animation = "Fly"
|
||||
@ -120,7 +120,7 @@ frame = 3
|
||||
playing = true
|
||||
offset = Vector2( 0, -12 )
|
||||
|
||||
[node name="ShadowSprite" type="Sprite" parent="."]
|
||||
[node name="ShadowSprite" type="Sprite2D" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
Reference in New Issue
Block a user