public void CreateLaser(Vector3 pos, Vector3 dir) { if (MagazineLoaded) { LaserController laserController = new LaserController(); AttachController(laserController); laserController.Shoot(pos, dir); } }
public void TriggerCollision(Collision collision) { if (collision.gameObject != lastCollision) { lastCollision = collision.gameObject; Vector3 copyDirection = Vector3.Reflect(direction, collision.gameObject.transform.up); for (int i = 0; i < gameManager.CollisionCopies && laserManager.MagazineLoaded; i++) { float spread = gameManager.CopiesSpread; Vector3 randomizedDirection = Quaternion.Euler(Random.Range(-spread, spread), Random.Range(-spread, spread), Random.Range(-spread, spread)) * copyDirection; LaserController tempController = Clone(); tempController.Shoot(collision.GetContact(0).point, randomizedDirection); } DestroyInstance(); } }