private void ArrowShoot() { LaneSelector laneSelector = FindObjectOfType <LaneSelector>(); if (Input.GetKeyDown(KeyCode.LeftArrow)) { GameObject laser = Instantiate(blueLaserPrefab, laneSelector.GetBottomPosition(), Quaternion.identity) as GameObject; } if (Input.GetKeyDown(KeyCode.RightArrow)) { GameObject laser = Instantiate(redLaserPrefab, laneSelector.GetBottomPosition(), Quaternion.identity) as GameObject; } }
// Start method is here to assign the target desintation of the gem and have it change for the // lifetime if the instance of this laser void Start() { LaneSelector laneSelector = FindObjectOfType <LaneSelector>(); if (laneSelector.GetBottomPosition() == centreBottomCoords) { this.targetPosition = centreTopCoords; } else if (laneSelector.GetBottomPosition() == leftBottomCoords) { this.targetPosition = leftTopCoords; } else if (laneSelector.GetBottomPosition() == rightBottomCoords) { this.targetPosition = rightTopCoords; } }
// when creating this function need to pass in the class and assign it to the instance at the start of the function, this is where unity asks for the script // to be passed in at the inspector public void RedShot(LaneSelector laneSelector) { GameObject laser = Instantiate(laserPrefab, laneSelector.GetBottomPosition(), Quaternion.identity) as GameObject; }