I'm having trouble coding a melee attack script.
I've set up an attack hitbox that toggles enabled/disabled whenever you press a button (The hitbox itself doesn't move, it just blinks in and out) and I'm trying to have it hit an unmoving target. The first hit gets registered, but the next do not unless I move either the static target (by pushing it) or the player itself.
Both the hitbox and the hurtbox have kinematic rigidbodies in them. They are separate BoxCollider2Ds in their own "Hitbox" and "Hurtbox" layers, which only interact between themselves. My hit detection code is as follows:
void OnTriggerEnter2D(Collider2D col) { Debug.Log(col + " got hurt"); } Here's a graphical example of what's going on. You can see how hit detection doesn't work until I nudge Test Monster. When I try to attack it without moving it, detection stops working.
