Improved Bunny Map collisions

This commit is contained in:
Snoweuph 2023-04-16 14:36:10 +02:00
parent 5b71f2c3de
commit fe89b4a00d
3 changed files with 5 additions and 14 deletions

View file

@ -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")

View file

@ -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

View file

@ -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