void Update() { if (Input.GetKeyDown(KeyCode.Space)) { var go = new GameObject("Grenade Out!"); go.transform.position = transform.position + transform.right * 0.5f + transform.up * 0.5f; var visible = Instantiate <GameObject>(ProjectilePrefab, go.transform); foreach (var collider in new List <Collider>(visible.GetComponentsInChildren <Collider>())) { Destroy(collider); } // initial toss motion Vector3 tossVelocity = transform.forward * RelativeMotion.z + transform.up * RelativeMotion.y; // maybe add in user motion if (GetTosserMotion != null) { tossVelocity += GetTosserMotion(); } // parabolic motion Ballistic3D.Attach(go, tossVelocity, GravityForThisWeapon); // this gets called when the RaycastSensor notices you hit something System.Action <Vector3> OnHit = (pos) => { Instantiate <GameObject>(ExplosionPrefab, pos, Quaternion.identity); damager.ApplyDamage(pos, DamageConfig); Destroy(go); }; RaycastSensor.Attach(go, OnHit); // death sentence TTL.Attach(go, 10.0f); // make it tumble var spinner = go.AddComponent <SpinMeAllAxes>(); spinner.RateOfSpin = Random.onUnitSphere * Random.Range(1000, 2000); } }