MonoBehaviour { //SetGravityにtrue/falseを渡すことで重⼒および物理⼲渉のOn/Offを切り替える public void SetGravity(bool flag) { gameObject.GetComponent<Rigidbody>().useGravity = flag; gameObject.GetComponent<Rigidbody>().isKinematic = !flag; } //Called when collision is occured private void OnCollisionEnter(Collision collision) { SetGravity(false); } }