Added Dark Souls/Elden Ring Dodging or ,’Invincibility Frame’ During Boosting To My 2D Shooter

PieceofPhie
2 min readJul 28, 2021

The player will now be able to dodge into bullets without receiving damage. Damage will only be taken if the player isn’t dodging or has collided with an enemy ship.

This requires one boolean that is flipped true or false when,’Boosting’.

Checking if the player is dodging

a boolean named ,’isdodging’ is being modified every time the player is boosting. when the player is boosting it’ll be assigned true and the inverse when the player isn't. Here’s the code snippet below.

The code snippet above is a script that was covered in a previous article. it entails on how the player boosts.

https://vixian.medium.com/day-24-booster-ui-and-camera-shake-645abd06f297

It is quite a chunk to look at so I tried making it easier to find the boolean by commenting a pointed arrow to them.

During the boost coroutine, the boolean is set to true and then set to false in the decelerate coroutine.

Checking if isDodging is true when taking damage

the boolean is then inserted into a conditional statement to insure that the player only takes damage when not dodging.

Gameplay Issue

There were minor issues that occurred when implementing this new mechanic. Bullets and enemies were still colliding with the player when the player dodged. This meant that the player was able to destroy everything by dodging into everything. Taking no damage whatsoever.

To fix this, I removed the basic destroy() function out of the enemy’s laser and the enemy itself.

My damage function has a additional GameObject parameter as seen above. the damage function will destroy any game object that is passed to it. So now the player will take damage accordingly as well as objects being destroyed when intended.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

PieceofPhie
PieceofPhie

Written by PieceofPhie

Unity Developer Based out of California

No responses yet

Write a response