Score is counting twice when both lasers hits same time

Greetings!

I’ve just noticed one of the enemy object is counting twice. I used Debug.Log when the colission happened and it seems it is counting left laser and right laser together (because they are hitting exact same time. That particular enemy object and both lasers have 90 degree angle).

I could’t find why this is happening. Would you please help me?

This is what I tried:

  • There are no two enemy scripts in that game object. I’ve checked this.
  • I tried to decrease start speed of lasers. Nothing changed.
  • I tried do instantiate crush particle another place because It might be hitting the clone is increasing score somehow.

Hi,

First of all, good job on analysing the problem. You figured out that two lasers hit the enemy at the same time, thus the score is counting twice. The code is obviously correct because we didn’t implement any restriction to prevent that from happening.

The question is: What behaviour would you prefer?

Depending on your goal, you could, for example, use Time.frameCount and a variable to figure out if the enemy was already hit in the current frame.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms