private void Update() { //toggle between cannons if (Input.GetKeyDown(KeyCode.Tab)) { if (isCannon1) { currentCannon = cannons_Outline.getCannon2Renderer(); groundPos = outline.getPosition(167, true); //cannon2 is at pt 167 isCannon1 = false; } else { currentCannon = cannons_Outline.getCannon1Renderer(); groundPos = outline.getPosition(10, true); isCannon1 = true; } } }
// Start is called before the first frame update void Start() { //create the terrain outline (different at each game) outline = terrain.GetComponent <createOutline>(); outline.createTerrain(); cannons_Outline = cannons.GetComponent <cannonsOutline>(); cannons_Outline.createCannons(outline); currentCannon = cannons_Outline.getCannon1Renderer(); groundPos = outline.getPosition(10, true); //cannon1 is at pt 10 //call every 2s the wind method to generate new value InvokeRepeating("WindChanges", 1.0f, 2.0f); //display the initial values of wind and velocity velocityTxt = GameObject.Find("veloText").GetComponent <Text>(); windTxt = GameObject.Find("windText").GetComponent <Text>(); velocityTxt.text = "Muzzle velocity : " + muzzleVelocity.ToString(); windTxt.text = "Wind : " + wind.ToString(); }