void Update() { if (Input.GetMouseButtonDown(0)) { dynDart = (GameObject)Instantiate(GameObject.Find("StaticDart")); dynDart.name = "DynDart"; dynDart.AddComponent <SimpleMotionR>(); SimpleMotionR smr = dynDart.GetComponent <SimpleMotionR>(); smr.moveSpeed = moveSpeed; dynDart.AddComponent <Rigidbody>(); Rigidbody rb = dynDart.GetComponent <Rigidbody>(); rb.useGravity = false; Transform ball = dynDart.transform.FindChild("dart1").FindChild("group19").FindChild("polySurface18"); Transform bar = dynDart.transform.FindChild("dart1").FindChild("group19").FindChild("polySurface19"); ball.gameObject.AddComponent <SphereCollider>(); bar.gameObject.AddComponent <CapsuleCollider>(); } }
// Use this for initialization void Start() { SimpleMotionR sm = gameObject.GetComponent <SimpleMotionR> (); GameObject.Destroy(sm); }