[Question]Laser hitting twice problem

Hello,

in LaserDefender,
sometimes in certain situations and angles when the laser hits the player it does double the damage it should do…

Happens mostly when I hit the laser from the side.

Maybe it is because after another frame in the update function, the laser is still colliding with the player so it decreases health twice…

I don’t know

How can I solve this?

Here’s the link to the thread I created - you can take a look… https://www.udemy.com/unitycourse/learn/v4/questions/3048536

And here’s a link to my project https://www.dropbox.com/s/ldao1itfk7bsio7/Laser_Defender.rar?dl=0

1 Like

Hello Ori, how are you?
Would you mind pasting the Projectile script?

1 Like

Hi, Ori.

I did opened your project and the issue is that the enemy laser object is not destroyed when it hits the player, so it continue to trigger the collider thus resulting in multiple damages.

When sharing project you can safely delete the library folder. It is only temporary files that unity will regenerate.

There is a lot of effort and creativity in your game, good job!

2 Likes

Just like I suspected then.

Ori,

If you have not read yet Frank’s (cool name BTW! :joy:) post yet, I suggest to try solving this first by what I asked you yesterday on Udemy:

Okay, I think it’s going to be what came in mind when I read your message on discord.
Look at your Projectile.cs script(it’s short enough) and try to figure out what might be missing from your Player_Controller.

Answer these questions:

How come the projectile can hit twice?

How were you going to avoid that?

We now have been trying to help you on 3 different platforms, so I hope it gets sorted for you now. :wink:

1 Like

Privacy & Terms