0 votes

I wanted to make a simple player fighting mechanic, so i set a simple code

    onready var sword_hitbox = $Hitbox_pivot/Hitbox
if Input.is_action_pressed("attack"):
    $sworda.play("slash")
    sword_hitbox.monitorable = true
else:
    $sworda.play("idle")
    sword_hitbox.monitorable = false

The problem is that when my "sword hitbox area" is already in the "enemy hurtbox area", the monitorable is still false even when i press attack. So i have to exit the "hurtbox area" and press the attack button, and enter the "hurtbox area" to let the "hurtbox" detect my sword hitbox area. and its annoying.

note: when i press attack button, the hitbox is set to monitorable so that it can be detected to let the enemy take damage

But i wanted let the "enemy hurtbox area to detect the "hitbox area" even when its already in the "hurbox area"

Godot version godot 3.4
in Engine by (15 points)

1 Answer

+1 vote
Best answer

So You are saying area collision is not triggered when set monitorable to true while already in collision. You can use collisionshape.disabled instead. You can use setcollision_mask instead. You can set scale of collision shape from 0 to base. At least one of these must be triggered when already overlapping another area :)

Alternatively You can get collisions without the signal :

if Input.is_action_pressed("attack"):
         for area in sword_hitbox.get_overlapping_areas():
                  area.triggertakedamage()
by (8,101 points)
selected by

I found out you can easily use the disabled property, but thanks Inches for helping!

if Input.is_action_pressed("attack"):
    $HitboxPivot/Hitbox/CollisionShape2D.disabled = false
else:
    $HitboxPivot/Hitbox/CollisionShape2D.disabled = true
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.