Tut19 Complete: Camera
This commit is contained in:
@ -21,6 +21,7 @@ onready var sprite = $AnimatedSprite
|
||||
onready var stats = $Stats
|
||||
onready var playerDetectionZone = $PlayerDetectionZone
|
||||
onready var hurtbox = $Hurtbox
|
||||
onready var softCollision = $SoftCollision
|
||||
|
||||
func _physics_process(delta):
|
||||
knockback = knockback.move_toward(Vector2.ZERO, 200 * delta)
|
||||
@ -43,8 +44,11 @@ func _physics_process(delta):
|
||||
state = IDLE
|
||||
sprite.flip_h = velocity.x < 0
|
||||
|
||||
if softCollision.is_colliding():
|
||||
velocity += softCollision.get_push_vector() * delta * 400
|
||||
velocity = move_and_slide(velocity)
|
||||
|
||||
|
||||
func seek_player():
|
||||
if playerDetectionZone.can_see_player():
|
||||
state = CHASE
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=18 format=2]
|
||||
[gd_scene load_steps=20 format=2]
|
||||
|
||||
[ext_resource path="res://Enemies/Bat.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Shadows/SmallShadow.png" type="Texture" id=2]
|
||||
@ -7,6 +7,7 @@
|
||||
[ext_resource path="res://Stats.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://Enemies/PlayerDetectionZone.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://Overlap/SoftCollision.tscn" type="PackedScene" id=8]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=1]
|
||||
atlas = ExtResource( 1 )
|
||||
@ -49,6 +50,9 @@ radius = 61.0328
|
||||
[sub_resource type="CircleShape2D" id=10]
|
||||
radius = 5.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id=11]
|
||||
radius = 5.0
|
||||
|
||||
[node name="Bat" type="KinematicBody2D"]
|
||||
collision_layer = 16
|
||||
script = ExtResource( 4 )
|
||||
@ -56,7 +60,6 @@ script = ExtResource( 4 )
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = SubResource( 6 )
|
||||
animation = "Fly"
|
||||
frame = 1
|
||||
playing = true
|
||||
offset = Vector2( 0, -12 )
|
||||
|
||||
@ -64,9 +67,11 @@ offset = Vector2( 0, -12 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
shape = SubResource( 7 )
|
||||
|
||||
[node name="Hurtbox" parent="." instance=ExtResource( 3 )]
|
||||
visible = false
|
||||
collision_layer = 8
|
||||
|
||||
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
|
||||
@ -77,21 +82,29 @@ shape = SubResource( 8 )
|
||||
max_health = 2
|
||||
|
||||
[node name="PlayerDetectionZone" parent="." instance=ExtResource( 6 )]
|
||||
visible = false
|
||||
|
||||
[node name="CollisionShape2D" parent="PlayerDetectionZone" index="0"]
|
||||
modulate = Color( 1, 1, 1, 0.258824 )
|
||||
shape = SubResource( 9 )
|
||||
|
||||
[node name="Hitbox" parent="." instance=ExtResource( 7 )]
|
||||
visible = false
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" parent="Hitbox" index="0"]
|
||||
position = Vector2( 0, -15 )
|
||||
shape = SubResource( 10 )
|
||||
|
||||
[node name="SoftCollision" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
[node name="CollisionShape2D" parent="SoftCollision" index="0"]
|
||||
shape = SubResource( 11 )
|
||||
|
||||
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
||||
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]
|
||||
|
||||
[editable path="Hurtbox"]
|
||||
[editable path="PlayerDetectionZone"]
|
||||
[editable path="Hitbox"]
|
||||
[editable path="SoftCollision"]
|
||||
|
Reference in New Issue
Block a user