diff --git a/Prefabs/bunny.tscn b/Prefabs/bunny.tscn index ebacb0e..fd558e4 100644 --- a/Prefabs/bunny.tscn +++ b/Prefabs/bunny.tscn @@ -114,9 +114,8 @@ _data = { [sub_resource type="CircleShape2D" id="CircleShape2D_nil6g"] radius = 11.0 -[node name="Bunny" type="Area2D" node_paths=PackedStringArray("animation_player", "agent")] +[node name="Bunny" type="CharacterBody2D" node_paths=PackedStringArray("animation_player", "agent")] collision_layer = 4 -collision_mask = 0 script = ExtResource("1_1kj2b") animation_player = NodePath("BunnyAnimator") agent = NodePath("NavigationAgent") diff --git a/Scripts/EntitySystem/Bunny.gd b/Scripts/EntitySystem/Bunny.gd index 21b4732..76c73ae 100644 --- a/Scripts/EntitySystem/Bunny.gd +++ b/Scripts/EntitySystem/Bunny.gd @@ -1,4 +1,4 @@ -extends Node2D +extends CharacterBody2D class_name Bunny @export var animation_player : AnimationPlayer @@ -59,7 +59,7 @@ func _physics_process(delta): time_since_got_player = 10.0 time_since_got_move_location = 10.0 else: - self.translate(move_velocity) + move_and_collide(move_velocity) else: animation_player.stop() time_since_got_player += delta diff --git a/Scripts/WeaponSystem/Projectile.gd b/Scripts/WeaponSystem/Projectile.gd index 4749bf7..345c8a6 100644 --- a/Scripts/WeaponSystem/Projectile.gd +++ b/Scripts/WeaponSystem/Projectile.gd @@ -28,17 +28,9 @@ func _on_collision(body): if collided_layer & map_collision_layer: queue_free() - pass - - -func _on_area_entered(area): - var collided_layer = null; - - if(area.has_method("get_collision_layer")): - collided_layer = area.get_collision_layer() - if collided_layer & bunny_collision_layer: - var bunny = area as Bunny + var bunny = body as Bunny bunny.damage(damage) queue_free() pass +