Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | rainswell |
Hi, I’m making a zeldalike where you can walk around, get hit by enemies, and hit them back with a sword. I have an enemy (a bee) that has a sight box, a circle around it so it can detect the player and start moving towards him.
The issue is that this sight box “hits” the player, causing him to take damage.
The sight box has no layer, and its mask it set to only see the player. The player’s hurtbox is set on the player layer, and its mask is set to only see enemies.
My understanding is that this setup would cause the hurtbox to never register the sight box, because the sight box has no layer. But of course, the sight box would see the player, because its mask is set to look for the player.
Can anyone tell me what I’m doing wrong, or how I’m misunderstanding the system? It seems like what’s happening is that if a collision is registered in one direction (i.e. the sightbox registering the player) somehow that necessitates the collision registering in the other direction (the hurtbox registering the sight box)? Is that what’s happening? And if so, that seems counterintuitive to say the least. How should I get past this?
Thanks very much.
Please post some more code would be helpful to know how you connected your signals, and where the function that applies damage to the player is happening. Also, are you using area2D? Or physics bodies?
What you’re trying to do should be possible and fairly simple. Likely just a little mistake somewhere
rossunger | 2022-02-15 17:15
func _on_hurtbox_area_entered(area):
get_hit()
func get_hit():
deplete_pod()
emit_signal("on_grip_changed", current_pod_fill)
I guess I should explain a little more, yeah the game actually takes place on a climbing wall, so the player has grip rather than health. There is a ‘grip’ node which has the above code on it, which it receives as a signal from the player’s hurtbox. As mentioned above, the hurtbox is what has its layer as player and the mask as enemy. So far it is done through Area2Ds rather than bodies.
So my understanding is that the hurtbox, in only being able to sense areas of type enemy through its mask, would not see the sight box, because the sight box has no layer- by my understanding the sight box itself should be essentially invisible to everything else. Is this accurate, or have I misunderstood something?
rainswell | 2022-02-15 20:57