//Runs at the beginning of bullet existence. void Start() { angleOfShot = GameObject.Find("RootShoot").GetComponent <Shoot>().currentGun.transform.rotation.eulerAngles.z; //initial variables crosshair = GameObject.Find("Crosshair"); //The GameObject instance variable "crosshairObj" is defined as the GameObject found with the name "CrosshairProxy". crosshairObj = GameObject.Find("CrosshairProxy"); //The instance variable Transform object "crosshairTransform" is defined as the transform of crosshairObj. crosshairTransform = crosshairObj.transform; //The GameObject instance variable "player" is defined as the GameObject found with the name "Player". player = GameObject.Find("Player"); rootShoot = GameObject.Find("RootShoot"); proxycursor = GameObject.Find("CrosshairProxy").GetComponent <proxyCursor>(); //The transform.right is one of the orientation's of a GameObject. This line points this object's transform.right orientation towards the crosshair. transform.right = crosshairTransform.position - transform.position; //Add random rotation based on the "vary" float variable. transform.Rotate(0, 0, Random.Range(-vary, vary)); rootShoot.GetComponent <Shoot>().swapEnable = false; rootShoot.GetComponent <Shoot>().shootEnable = false; /* * if(Vector2.Distance(transform.position,player.transform.position) < 0.5f) * { * * } */ upSpeed = speed; if (timeToStop != -1 && !canBeHeld) { LeanTween.value(gameObject, speed, 0f, timeToStop).setOnUpdate((float val) => { upSpeed = val; }); } released = false; if (hasFuse) { currentFuseTime = fuseTime; } currentControlTime = controlTime; //removes this object from existance. Destroy(gameObject, lifetime); }
// Start is called before the first frame update void Start() { sprite = GetComponent <SpriteRenderer>(); rootShoot = GameObject.Find("RootShoot").transform.GetComponent <Shoot>(); if (proxycursor == null) { if (GameObject.Find("CrosshairProxy") != null) { proxycursor = GameObject.Find("CrosshairProxy").GetComponent <proxyCursor>(); } } }
// Start is called before the first frame update void Start() { if (GameObject.Find("Player")) { player = GameObject.Find("Player"); } sprite = GetComponent <SpriteRenderer>(); origX = transform.localPosition.x; rootShoot = GameObject.Find("RootShoot").transform.GetComponent <Shoot>(); if (proxycursor == null) { if (GameObject.Find("CrosshairProxy") != null) { proxycursor = GameObject.Find("CrosshairProxy").GetComponent <proxyCursor>(); } } }