void Fire() { Needle currentNeedle = GetComponentInChildren <Needle>(); currentNeedle.GetComponent <Needle>().triggered = true; currentNeedle.transform.parent = null; }
//--------------------------------------------------------------- // Use this for initialization void Start() { ConvertPowerToDamage(shotPower); //TODO replace FindObjectOfType by FindObjectByTag Needle needle = GameObject.FindObjectOfType <Needle>(); if (!needle) { return; //exit if no needle found } Transform needleTransform = needle.GetComponent <Transform> (); transform.rotation = needleTransform.rotation; Vector3 shotDerivingPosition = needleTransform.right; rg2D = this.GetComponent <Rigidbody2D>(); rg2D.velocity = new Vector2(shotSpeed * shotDerivingPosition.x, shotSpeed * shotDerivingPosition.y); }