Beispiel #1
0
    //
    public void Update()
    {
        if (Owner)
        {
            if (GameObj.GetComponent <Rigidbody>().useGravity&& !GameObj.GetComponent <Rigidbody>().IsSleeping())
            {
//				Debug.Log ("HatObject.Update() : hat=" + name + ", velocity=" + GameObj.rigidbody.velocity);

                if (GameObj.transform.position.y < (Owner.Position.y - 10.0f))                 //when we're too much below our owner, sleep the physics
                {
                    GameObj.GetComponent <Rigidbody>().Sleep();
//					Debug.Log ("SLEEP HatObject.Update() : hat=" + name + ", velocity=" + GameObj.rigidbody.velocity + ", pos=" + GameObj.transform.position);
                }
            }
        }

        if (DestroyTime > 0 && Time.timeSinceLevelLoad > DestroyTime)
        {
            if (Owner)
            {
                Owner.DestroyHat();
            }
            else
            {
                Destroy(GameObj);
            }
        }
    }