I'm trying to pick up an enemy and make it stay in a specific spot when the body enters the area above my player's head. I made a separate area and collision for it, but it doesn't seem to be detecting anything.

I'm 99% I set up all my layers and masks properly cuz I triple checked, but maybe I'm missing something? If anyone wants to help, I'd greatly appreciate it.

I'll share the project again.

practice.zip
4MB
  • xyz replied to this.
  • NJL64 Right, enemy's HeadDetector stays enabled. But Player's Head does not have the area_entered signal connected, only body_entered, which would not catch that collision because HeadDetector is an area, not a body. So connect Head's area_entered and it'll work.

    However this is extremely convoluted way of doing it. You actually don't need any additional colliders. Simply re-parent the enemy to the player when it's grabbed and send it to wanted location via tween. When the tween is finished, switch the state to "carried" and you're done.

    NJL64 It doesn't detect it because your code disables enemy's collider once the state is switched to "grabbed".

      xyz All of them? Including the one connected to Area2D? I don't know that that's the case, because the Area2D's collision shape is visible when I test it.

      I'll experiment around with that a little more.

      • xyz replied to this.

        NJL64 Right, enemy's HeadDetector stays enabled. But Player's Head does not have the area_entered signal connected, only body_entered, which would not catch that collision because HeadDetector is an area, not a body. So connect Head's area_entered and it'll work.

        However this is extremely convoluted way of doing it. You actually don't need any additional colliders. Simply re-parent the enemy to the player when it's grabbed and send it to wanted location via tween. When the tween is finished, switch the state to "carried" and you're done.

          xyz I literally just figured it out and came here to tell everyone to disregard lol.

          Thank you very much for providing me with the answer and making the effort to help me. Yes. It was because I was using body entered instead of area entered. I switched it and now it works.

          Again, thank you very much!