Only using One Laser

So unfortunately, when we picked out our ships the instructor neglected to mention that we needed a ship with dual lasers. So I chose ship 18, and have already created my animation on the object so I am absolutely not redoing all of that just for a new ship with 2 layers. So I likely don’t need an arrayay, but I am not sure what my “Pivate void ActivateLaser()” code line should be. I attempted "if (GameObject laser in laser) but there is a lot of red in my script now. Would I instead use “if Input.GetButton()”?

Since you only have one laser, you don’t need the foreach part. the rest will be the same

var emissionModule = laser.GetComponent<ParticleSystem>().emission;
emissionModule.enabled = isActive;

This assumes your reference is laser (with no array)

[Header("Laser gun")]
[Tooltip("Add the player laser here")]
[SerializeField] GameObject laser;

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

Privacy & Terms