static public int WakeUp(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
         self.WakeUp();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 2
0
 private void Start()
 {
     r = GetComponent<Rigidbody>();
     if (r)
     {
         r.WakeUp();
         r.useGravity = false;
         r.freezeRotation = true;
         r.isKinematic = false;
     }
 }
Ejemplo n.º 3
0
 static public int WakeUp(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
         self.WakeUp();
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 4
0
 static int WakeUp(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Rigidbody obj = (UnityEngine.Rigidbody)ToLua.CheckObject(L, 1, typeof(UnityEngine.Rigidbody));
         obj.WakeUp();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 5
0
 void enableRigidBody(Rigidbody p_rbody)
 {
     p_rbody.isKinematic = false;
     p_rbody.detectCollisions = true;
     p_rbody.WakeUp();
 }
Ejemplo n.º 6
0
    protected virtual void OnEnable()
    {
        _frame = Random.Range(0, Interval);
        _interval = Interval;

        Rigidbody = GetComponentInParent<Rigidbody>();
        Rigidbody.WakeUp();
    }
Ejemplo n.º 7
0
    void ThrowOrStoreItem()
    {
        Vector3 resultingDirection = (item.transform.position - previousItemPosition);

        // To track if handmovement is quick enough that the player wants to throw
        float maxThrowForce = Mathf.Abs(Mathf.Max(resultingDirection.x, resultingDirection.y, resultingDirection.z)) * 10.0f;

        //Debug.Log(maxThrowForce);

        if(inventory.isItemTouchingInventory(item.gameObject) && maxThrowForce < 0.2f)
        {
            inventory.storeItem(item, itemIsUsable, itemParent);
        }
        else
        {
            //print ("ThrowItem() called!");
            itemRigid = item.GetComponent<Rigidbody>();
            itemRigid.isKinematic = false;
            if(itemRigid.IsSleeping())
            {
                itemRigid.WakeUp();
            }
            itemRigid.AddForce(resultingDirection * 1/Time.deltaTime * 1.4f,ForceMode.VelocityChange);
            /*
            if(maxThrowForce < .3f)
            {
                itemRigid.AddForce(resultingDirection * 1/Time.deltaTime,ForceMode.VelocityChange);
            }
            else
            {
                itemRigid.AddForce(resultingDirection * 1/Time.deltaTime * 2.0f,ForceMode.VelocityChange);
            }
            */
            //print ("Added Force!");

            Collider[] colliders = item.GetComponents<Collider>();
            for(int i=0; i<colliders.Length; i++)
            {
                colliders[i].isTrigger = false;
            }

            if(itemParent != null)
            {
                if(!itemParent.Equals(hand.transform) || !item.transform.parent.name.Contains("unterarm"))
                {
                    //print("Parent ist not hand");
                    item.transform.parent = itemParent;
                }
            }
            else
            {
                item.transform.parent =  null;
            }

            if (itemIsUsable)
            {
                item.layer = 14;
            }
            else
            {
                item.layer = 9;
            }
            CheckItemUnderWorld();
        }

        if(itemIsUsable)
        {
            itemClass.OnDeequip();
            itemClass = null;
        }

        item = null;
        itemIsInHand = false;
        itemIsUsable = false;
    }