Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class VoltageControl : MonoBehaviour {
- public GameObject scoreText; //shows the voltage
- public GameObject NegPoint; //negative part of battery
- public GameObject PosPoint; //positive part of battery
- private ChargeNum posScript; //script for the posiitve connection of the battery that detects if it touched the voltmeter
- private ChargeNum2 negScript; //script for the negative connection of the battery that detects if it touched the voltmeter
- public int charge = 0;
- // Use this for initialization
- void Start () {
- posScript = PosPoint.GetComponent<ChargeNum>(); //get the script
- negScript = NegPoint.GetComponent<ChargeNum2>();//get the script
- scoreText.GetComponent<Text>().text = "Charge" + charge; //setup the text for the voltage
- }
- // Update is called once per frame
- void Update () {
- if(negScript.linked==true && posScript.linked == true) //if both connections are made
- {
- charge += 5;//increase charge by 5
- scoreText.GetComponent<Text>().text = "Charge" + charge;//get the script
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement