I’m pretty new to unity2D and was wondering how I would go about adding hit/hurt boxes to my character?
Would it possible to use an asset like smoothmoves to animate and then attach the hitboxes to the character that way?
I’m looking to do something like the hit/hurtbox below.
Is there a way I could do this using the built in unity collider engine? and could someone point me in the right direction regarding tutorials/etc. like… what would I need to know to do something like this.
I been looking around a bunch and just couldnt find anything.
Typically, you’d set up one or more colliders (you can always add colliders to child objects if you need collisions on different layers or parameters) to both the targets and the attacks, and detect when they collide. If you want the collision to be ignored for physics purposes, you set them to “trigger”. Then, you catch the event in a script to determine what happens (e.g. damage/destruction).
Colliders are actually components of game objects, rather than GameObjects in their own right. If you want a GameObject to detect and/or react to collisions, just go to AddComponent in the inspector, select Physics2D, then select one of the Collider components (circle or box for simple shapes, but polygon will give you more control over the shape). You can then set the Collider to Trigger if you don’t want it to bounce from the physics engine.
Once the colliders are in place, you’ll need to catch those collision events in a script to do something like taking damage.
BTW, the 2D Overview actually does exactly this, where the projectiles use trigger colliders to detect impacts on targets, which then either take damage or get destroyed.