fbpx

 

triple shot prefab ...
 

triple shot prefab is adding score 3 times  

   RSS

0

i have them all tag as laser and think thats the problem any ideas.

Topic Tags
3 Answers
0

Make sure to turn off the Enemy collider as soon as the Laser hits it before anything else. This should insure that only one laser is seeing the Enemy . 

@thom-foxx

if you have any ideas that be great i been looking around and cant find how to disable box collider 2d

@thom-foxx

Hi Thom,
I don't get the logic of turning off the Enemy Collider.
A collision with either the Player or a Laser results in the Enemy being transported in the same frame to the spawnZone (above the Viewport )
Turning off the collider would require turning it back on, which would make the code a little more convoluted.
It's possible I've strayed from the path somewhere and my functionality differs from the intended 🙂
Regards,

0

any ideas what that code would look like and i found this gameObject.GetComponent(collider type).isTrigger = true;

0

i think i got it to work for shooting into the enemy multiple time would add score, but still having same issue with disabling box collider 2d

private BoxCollider2D boxcollider2d;

OnTriggerEnter2D method

boxcollider2d = gameObject.GetComponent<BoxCollider2D>() as BoxCollider2D;
boxcollider2d.size = new Vector2(.0f, .0f);
boxcollider2d.isTrigger = true; 

seem to work when i set the floats to 0f;

that what i found on unity3d website 

This post was modified 2 weeks ago 4 times by Dominick H

@domhuff26gmail-com

Should be something along the lines ".enabled".

At work, so cant check for sure.

hey no problem and thanks

@domhuff26gmail-com

if (other.tag == "Laser")
{
_canvas.UpdateScore(10);
_isDead = true;
Destroy(other.gameObject);
_animator.SetTrigger("OnEnemyDeath");
_enemySpeed = 0.5f;
_collider.enabled = false;
_audiosource.PlayOneShot(_explosionSound);
Destroy(this.gameObject, 3.5f);

}

Share:

 

 

Scroll to Top

Please Login or Register