Attacking with Hitbox- Game Dev Series 104

Objective: create a hitbox attacking system.

See the green box on sword?

As we created the sword swing animation in 2D game to attack, how do we make it works like a real sword attack?
As always, we use collider as trigger.
In this article, we will create a hitbox attacking system to attack animation.

Hitbox collider

To create a hitbox, first we need a sprite. Add one to Player and set the sprite to UISprite as base sprite.

Then add a box collider 2D and a Rigidbody 2D to it and set collider as trigger.

Attach to attack animation

Then select Player Sprite object and choose Attack animation in Animation tab. We will adjust the Hit_Box to Attack animation frame by frame.
Before we do it, drag Hit_Box to Sprite as a child of it.
And remove the Sprite Renderer component of Hit_Box.

Then we can start adjusting Hit_Box in Animation.
When Attack animation is recording, moving and rotating Hit_Box to make it fit the sword in animation.

When it done, it should look like this.

Now you have created a hitbox to Player, in the next article we will continue to make this sword works.

--

--

--

A passionate gamer whose goal is to work in video game development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating our First project to Run Selenium script in Jenkins

How to Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT on Windows 10

Cloud Migration Challenges

Agile Project Planning (APP) — Part 1: Requirements Engineering (RE) is going to be agile!

Painless C++ Coroutine-Part 3

Tech debt in the cloud

5 mistakes that beginner software developers face when learning to code.

Brief Introduction of miniSEED and libmseed

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

Adding FPS Functionality to the Player Controller in Unity 2021

How I used scriptable objects to build a powerup system

The new Input System: installation