_on_area_entered works on other collision shapes when it shouldnt

Hey, you wont get any more answers if you set a solution btw :slight_smile: I would start a new topic or open it back up

Also, i dot know how exactly to fix it, but i believe your method might have been misspelled? Thats the only reason i could think

Yeah, appaeently you have to check if the variable is not null when its a reference returned by a function … this happens all the time you see the pattern in addons all over the place.

if not (local_parent == null) and local_parent.has_method("take_damage"):

local_parent will be null it isn’t a_hitbox. Are both the area and its parent supposed to be a_hitbox?

Lol yeah THE_HITBOX is a_hitbox, the local_parent should be assigned normally so just delete the ``as a_hitbox`` so the line should be

var local_parent = THE_HITBOX.get_parent()

Then its okay because you still check has_method() and the compiler/interpretor can figure that out … but if that doesnt work then try casting local_parent to the exact type - You can also type ``( local_parent as PARENT_CLASS).some_function()``

Basically the get_parent() returns the reference to the base class and you have to cast it or check if the method exists …

yeah it works now

but it always printed “Does not have method take damage”
i did some testing and the problem was

		var local_parent = THE_HITBOX.get_parent() as a_hitbox
		if local_parent.has_method("take_damage"):
			local_parent.take_damage(10)		

and i after reaplacing it with

	if get_parent().has_method("take_damage"):
		get_parent().take_damage(10)

it works and now it sees and calls the function

1 Like

Just what works is a good start as they say.