I cannot understand this Breakpoint.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ItzKillerTTV

Hello, again haha. I’m currently experiencing an issue where the game crashes with a breakpoint and I’m unsure what causes this. I am making a hurtbox/hitbox system and, at first, the game used to crash when I actually entered the hitbox of the enemy, but now it crashes every time I even open the project. I made an EnemyBase inhereted from an EntityBase, then added the following script to it:

extends KinematicBody2D

export(int) var hp_max: int = 100
export(int) var hp: int = hp_max

var velocity: Vector2 = Vector2.ZERO
export (int) var SPEED: int = 75

onready var animatedsprite = $AnimatedSprite
onready var collshape = $CollisionShape2D

func _physics_process(_delta): move()

func move(): velocity = move_and_slide(velocity)

func die(): queue_free()

func _on_Hurtbox_area_entered(hitbox): var base_damage = hitbox.damage self.hp -= base_damage print(hitbox.get_parent().name + "'s hotbox touched " + name + "'s hurtbox and dealt " + str(base_damage))

The Hitbox of the enemy just has the damage variable, this is Hitbox.gd:

extends Area2D

export(int) var damage: int = 10

Any ideas on how to fix this?

What error are you getting? And which line has the breakpoint?

SteveSmith | 2022-10-03 07:56

wait what ? The problem is that game crashes after setting up breakpoint in the code ? :wink:

Inces | 2022-10-03 20:27

When you say “crash”, you mean the whole of Godot crashes, or just your game?

SteveSmith | 2022-10-04 06:30

:bust_in_silhouette: Reply From: BigTuna675

It looks like in your _on_Hurtbox_area_entered(hitbox) function, any area at all can trigger this code. This is a problem if the triggering area does not contain a variable for damage, like you are assuming when you say var base_damage = hitbox.damage.

Try to ensure that the triggering area is the correct area. You can assign the triggering area to a group, and then in the _on_Hurtbox_area_entered(hitbox), return from the function immediately if the triggering area is not in the correct group.

As to why the game crashes immediately upon opening it, if there is an enemy overlapping any other area upon start-up, it will crash because of the above reasons (hard to say for certain what is happening without any other pictures or information, though).

Good luck!