Example #1
0
 private bool CreateSphere()
 {
     DestroyObject();
     CurGameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
     InitObject();
     CurGameObject.AddComponent <GameSphere>();
     CurGameObject.GetComponent <GameSphere>().ObjectLogic = this;
     return(true);
 }
Example #2
0
        private bool DropObject()
        {
            if (CurGameObject != null)
            {
                Rigidbody rigidbody = CurGameObject.GetComponent <Rigidbody>() as Rigidbody;
                rigidbody.useGravity = true;
            }

            return(true);
        }
Example #3
0
        private void InitObject()
        {
            Material defaultMaterial = null;

            foreach (var it in Resources.FindObjectsOfTypeAll(typeof(Material)))
            {
                if (it.name == PLAYER_MAT_NAME)
                {
                    defaultMaterial = it as Material;
                    break;
                }
            }

            CurGameObject.transform.position = INIT_POS;
            CurGameObject.GetComponent <MeshRenderer>().material = defaultMaterial;
            Rigidbody rigidbody = CurGameObject.AddComponent <Rigidbody>() as Rigidbody;

            rigidbody.useGravity = false;
            rigidbody.mass       = 1;
        }