Fixed stuck in enemy
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://but5aeh7y1s0f" path="res://game/characters/abstract_enemy.gd" id="1_2wrno"]
|
||||
[ext_resource type="PackedScene" uid="uid://dtxiercm8dsfm" path="res://game/characters/enemy_sprite.tscn" id="2_tjvyk"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpvsvsd8pcjqn" path="res://game/player_killer.tscn" id="4_vecdo"]
|
||||
[ext_resource type="PackedScene" uid="uid://dike8xgbqdut2" path="res://game/killing_area.tscn" id="3_tjvyk"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_mocsw"]
|
||||
radius = 4.0
|
||||
@@ -11,6 +11,10 @@ height = 28.0
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vecdo"]
|
||||
size = Vector2(32, 28)
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_tjvyk"]
|
||||
radius = 4.0
|
||||
height = 28.0
|
||||
|
||||
[node name="AbstractEnemy" type="CharacterBody2D" unique_id=1676614852]
|
||||
collision_layer = 0
|
||||
script = ExtResource("1_2wrno")
|
||||
@@ -21,8 +25,6 @@ script = ExtResource("1_2wrno")
|
||||
position = Vector2(0, 2)
|
||||
shape = SubResource("CapsuleShape2D_mocsw")
|
||||
|
||||
[node name="PlayerKiller" parent="." unique_id=1874600747 instance=ExtResource("4_vecdo")]
|
||||
|
||||
[node name="WallCheck" type="Node2D" parent="." unique_id=782156094]
|
||||
position = Vector2(0, 9)
|
||||
|
||||
@@ -68,6 +70,14 @@ collision_mask = 0
|
||||
position = Vector2(0, 2)
|
||||
shape = SubResource("RectangleShape2D_vecdo")
|
||||
|
||||
[node name="KillingArea" parent="." unique_id=1891922549 instance=ExtResource("3_tjvyk")]
|
||||
collision_layer = 0
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="KillingArea" unique_id=1710758452]
|
||||
position = Vector2(0, 2)
|
||||
shape = SubResource("CapsuleShape2D_tjvyk")
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]
|
||||
[connection signal="animation_looped" from="AnimatedSprite2D" to="." method="_on_animation_looped"]
|
||||
[connection signal="body_entered" from="PlayerTouchArea" to="." method="_on_player_touch_area_entered"]
|
||||
|
||||
@@ -1,39 +1,53 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cutjutvd8dqqc"]
|
||||
[gd_scene format=3 uid="uid://cutjutvd8dqqc"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d37eyum03h83i" path="res://game/characters/abstract_color_enemy.tscn" id="1_gj2ks"]
|
||||
[ext_resource type="Script" uid="uid://c2knsjcp6faf6" path="res://game/characters/black_enemy.gd" id="2_332ds"]
|
||||
[ext_resource type="Material" uid="uid://dggr8t4b30e3n" path="res://game/materials/enemy_black.tres" id="3_3jy5n"]
|
||||
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_3jy5n"]
|
||||
|
||||
[node name="BlackEnemy" instance=ExtResource("1_gj2ks")]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0u0ii"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("3_3jy5n")
|
||||
shader_parameter/black_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/white_color = Color(1, 1, 1, 1)
|
||||
shader_parameter/switch_colors = true
|
||||
shader_parameter/threshold = 0.5
|
||||
shader_parameter/speed = 5.0
|
||||
shader_parameter/intensity = 1.0
|
||||
shader_parameter/scale = 20.0
|
||||
|
||||
[node name="BlackEnemy" unique_id=1910124567 instance=ExtResource("1_gj2ks")]
|
||||
collision_layer = 4
|
||||
collision_mask = 3
|
||||
script = ExtResource("2_332ds")
|
||||
|
||||
[node name="AnimatedSprite2D" parent="." index="0"]
|
||||
material = ExtResource("3_3jy5n")
|
||||
[node name="AnimatedSprite2D" parent="." index="0" unique_id=1997264413]
|
||||
material = SubResource("ShaderMaterial_0u0ii")
|
||||
|
||||
[node name="CollisionSwitcher" parent="." index="2"]
|
||||
initial_state = 0
|
||||
|
||||
[node name="LeftWallRay" parent="WallCheck" index="0"]
|
||||
[node name="LeftWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="0" unique_id=521416854]
|
||||
collision_mask = 3
|
||||
|
||||
[node name="RightWallRay" parent="WallCheck" index="1"]
|
||||
[node name="RightWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="1" unique_id=1457669135]
|
||||
collision_mask = 3
|
||||
|
||||
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" index="0"]
|
||||
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="0" unique_id=947570027]
|
||||
target_position = Vector2(-32, 0)
|
||||
collision_mask = 11
|
||||
|
||||
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" index="1"]
|
||||
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="1" unique_id=1559118218]
|
||||
target_position = Vector2(32, 0)
|
||||
collision_mask = 11
|
||||
|
||||
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" index="0"]
|
||||
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="0" unique_id=1491085518]
|
||||
collision_mask = 11
|
||||
|
||||
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" index="1"]
|
||||
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="1" unique_id=1377654831]
|
||||
collision_mask = 11
|
||||
|
||||
[node name="PlayerTouchArea" parent="." index="7"]
|
||||
[node name="PlayerTouchArea" parent="." index="6" unique_id=2147163970]
|
||||
collision_mask = 8
|
||||
|
||||
[node name="KillingArea" parent="." index="7" unique_id=1891922549]
|
||||
collision_mask = 8
|
||||
|
||||
@@ -1,34 +1,37 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cb0w6mt8g4mer"]
|
||||
[gd_scene format=3 uid="uid://cb0w6mt8g4mer"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bx0luh4vdob3q" path="res://game/characters/abstract_enemy.tscn" id="1_q3s46"]
|
||||
[ext_resource type="Script" uid="uid://cern5veiqkrkc" path="res://game/characters/gray_enemy.gd" id="2_olede"]
|
||||
[ext_resource type="Material" uid="uid://dbkn3k0batj5w" path="res://game/materials/enemy_gray.tres" id="3_ho47d"]
|
||||
|
||||
[node name="GrayEnemy" instance=ExtResource("1_q3s46")]
|
||||
[node name="GrayEnemy" unique_id=139812221 instance=ExtResource("1_q3s46")]
|
||||
collision_layer = 16
|
||||
collision_mask = 35
|
||||
script = ExtResource("2_olede")
|
||||
|
||||
[node name="AnimatedSprite2D" parent="." index="0"]
|
||||
[node name="AnimatedSprite2D" parent="." index="0" unique_id=1997264413]
|
||||
material = ExtResource("3_ho47d")
|
||||
|
||||
[node name="LeftWallRay" parent="WallCheck" index="0"]
|
||||
[node name="LeftWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="0" unique_id=521416854]
|
||||
collision_mask = 35
|
||||
|
||||
[node name="RightWallRay" parent="WallCheck" index="1"]
|
||||
[node name="RightWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="1" unique_id=1457669135]
|
||||
collision_mask = 35
|
||||
|
||||
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" index="0"]
|
||||
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="0" unique_id=947570027]
|
||||
collision_mask = 171
|
||||
|
||||
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" index="1"]
|
||||
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="1" unique_id=1559118218]
|
||||
collision_mask = 171
|
||||
|
||||
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" index="0"]
|
||||
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="0" unique_id=1491085518]
|
||||
collision_mask = 171
|
||||
|
||||
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" index="1"]
|
||||
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="1" unique_id=1377654831]
|
||||
collision_mask = 171
|
||||
|
||||
[node name="PlayerTouchArea" parent="." index="6"]
|
||||
[node name="PlayerTouchArea" parent="." index="5" unique_id=2147163970]
|
||||
collision_mask = 136
|
||||
|
||||
[node name="KillingArea" parent="." index="6" unique_id=1891922549]
|
||||
collision_mask = 136
|
||||
|
||||
+17
-11
@@ -79,17 +79,13 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
_update_animation()
|
||||
|
||||
var was_collided := move_and_slide()
|
||||
if was_collided and _is_alive:
|
||||
for i in range(get_slide_collision_count()):
|
||||
var collision := get_slide_collision(i)
|
||||
if _is_killing_collider(collision.get_collider()) and _is_alive:
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_death, global_position)
|
||||
_is_alive = false
|
||||
collision_mask = 1
|
||||
get_tree().paused = true
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
sprite.play(ANIMATION_DEATH)
|
||||
move_and_slide()
|
||||
#var was_collided := move_and_slide()
|
||||
#if was_collided and _is_alive:
|
||||
#for i in range(get_slide_collision_count()): #TODO remove
|
||||
#var collision := get_slide_collision(i)
|
||||
#if _is_killing_collider(collision.get_collider()):
|
||||
#kill()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
@@ -98,6 +94,16 @@ func _input(event: InputEvent) -> void:
|
||||
collision_switcher.switch_color()
|
||||
|
||||
|
||||
func kill() -> void:
|
||||
if not _is_alive: return
|
||||
|
||||
SoundManager.play_sfx_stream(SoundManager.sfx_stream_death, global_position)
|
||||
_is_alive = false
|
||||
get_tree().paused = true
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
sprite.play(ANIMATION_DEATH)
|
||||
|
||||
|
||||
func add_pickup(pickup: AbstractPickup) -> void:
|
||||
pickup.reparent.call_deferred(pickups)
|
||||
_rearrange_pickups.call_deferred()
|
||||
|
||||
@@ -9,7 +9,7 @@ radius = 4.0
|
||||
|
||||
[node name="Player" type="CharacterBody2D" unique_id=508706417]
|
||||
collision_layer = 128
|
||||
collision_mask = 113
|
||||
collision_mask = 33
|
||||
script = ExtResource("1_xln5q")
|
||||
|
||||
[node name="AnimatedSprite2D" parent="." unique_id=237719081 instance=ExtResource("2_n6ad3")]
|
||||
|
||||
@@ -1,36 +1,50 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bv2gahb4wxgb1"]
|
||||
[gd_scene format=3 uid="uid://bv2gahb4wxgb1"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d37eyum03h83i" path="res://game/characters/abstract_color_enemy.tscn" id="1_3yi7g"]
|
||||
[ext_resource type="Script" uid="uid://dmcpkytgiuedi" path="res://game/characters/white_enemy.gd" id="2_c7pdf"]
|
||||
[ext_resource type="Material" uid="uid://ci7xuso12af5" path="res://game/materials/enemy_white.tres" id="3_uj6yw"]
|
||||
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="3_uj6yw"]
|
||||
|
||||
[node name="WhiteEnemy" instance=ExtResource("1_3yi7g")]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gfhm1"]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource("3_uj6yw")
|
||||
shader_parameter/black_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/white_color = Color(1, 1, 1, 1)
|
||||
shader_parameter/switch_colors = false
|
||||
shader_parameter/threshold = 0.5
|
||||
shader_parameter/speed = 5.0
|
||||
shader_parameter/intensity = 1.0
|
||||
shader_parameter/scale = 20.0
|
||||
|
||||
[node name="WhiteEnemy" unique_id=486389199 instance=ExtResource("1_3yi7g")]
|
||||
collision_layer = 64
|
||||
collision_mask = 33
|
||||
script = ExtResource("2_c7pdf")
|
||||
|
||||
[node name="AnimatedSprite2D" parent="." index="0"]
|
||||
material = ExtResource("3_uj6yw")
|
||||
[node name="AnimatedSprite2D" parent="." index="0" unique_id=1997264413]
|
||||
material = SubResource("ShaderMaterial_gfhm1")
|
||||
|
||||
[node name="LeftWallRay" parent="WallCheck" index="0"]
|
||||
[node name="LeftWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="0" unique_id=521416854]
|
||||
collision_mask = 33
|
||||
|
||||
[node name="RightWallRay" parent="WallCheck" index="1"]
|
||||
[node name="RightWallRay" parent="WallCheck" parent_id_path=PackedInt32Array(782156094) index="1" unique_id=1457669135]
|
||||
collision_mask = 33
|
||||
|
||||
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" index="0"]
|
||||
[node name="LeftPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="0" unique_id=947570027]
|
||||
target_position = Vector2(-32, 0)
|
||||
collision_mask = 161
|
||||
|
||||
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" index="1"]
|
||||
[node name="RightPlayerCloseRay" parent="PlayerCloseCheck" parent_id_path=PackedInt32Array(1593775088) index="1" unique_id=1559118218]
|
||||
target_position = Vector2(32, 0)
|
||||
collision_mask = 161
|
||||
|
||||
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" index="0"]
|
||||
[node name="LeftPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="0" unique_id=1491085518]
|
||||
collision_mask = 161
|
||||
|
||||
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" index="1"]
|
||||
[node name="RightPlayerDistantRay" parent="PlayerDistantCheck" parent_id_path=PackedInt32Array(1597489123) index="1" unique_id=1377654831]
|
||||
collision_mask = 161
|
||||
|
||||
[node name="PlayerTouchArea" parent="." index="7"]
|
||||
[node name="PlayerTouchArea" parent="." index="6" unique_id=2147163970]
|
||||
collision_mask = 128
|
||||
|
||||
[node name="KillingArea" parent="." index="7" unique_id=1891922549]
|
||||
collision_mask = 128
|
||||
|
||||
Reference in New Issue
Block a user