Esempio n. 1
0
 void OnCollisionEnter(Collision collision)
 {
     cloth.DetachFromCollider(col);
     cloth.AttachToCollider(col, false, true);
     cloth.stretchingStiffness = stiffness;
     rigidbody.constraints     = RigidbodyConstraints.FreezePosition;
 }
Esempio n. 2
0
    void OnColl(Vector3 point, Collider t)
    {
        AttachedTo = t.transform.GetComponentInParrent <Wall>();
        if (AttachedTo != null && AttachedTo.attachRope)
        {
            offs     = AttachedTo.transform.InverseTransformPoint(pos);
            attached = true;
            Cloth.DetachFromCollider(pl.RopeColl);
            Cloth.AttachToCollider(pl.RopeColl, false, true);
            rigidbody.isKinematic = true;
        }
        if (!attached)
        {
            EnableRope(false);
        }

        var p = t.transform.GetComponentInParrent <PhysAnim>();

        if (p != null)
        {
            if (p.PlayOnRopeHit && networkView.isMine)
            {
                p.RPCPlay();
            }
        }
    }
Esempio n. 3
0
    static int AttachToCollider(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            InteractiveCloth obj  = LuaScriptMgr.GetNetObject <InteractiveCloth>(L, 1);
            Collider         arg0 = LuaScriptMgr.GetNetObject <Collider>(L, 2);
            obj.AttachToCollider(arg0);
            return(0);
        }
        else if (count == 3)
        {
            InteractiveCloth obj  = LuaScriptMgr.GetNetObject <InteractiveCloth>(L, 1);
            Collider         arg0 = LuaScriptMgr.GetNetObject <Collider>(L, 2);
            bool             arg1 = LuaScriptMgr.GetBoolean(L, 3);
            obj.AttachToCollider(arg0, arg1);
            return(0);
        }
        else if (count == 4)
        {
            InteractiveCloth obj  = LuaScriptMgr.GetNetObject <InteractiveCloth>(L, 1);
            Collider         arg0 = LuaScriptMgr.GetNetObject <Collider>(L, 2);
            bool             arg1 = LuaScriptMgr.GetBoolean(L, 3);
            bool             arg2 = LuaScriptMgr.GetBoolean(L, 4);
            obj.AttachToCollider(arg0, arg1, arg2);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: InteractiveCloth.AttachToCollider");
        }

        return(0);
    }
Esempio n. 4
0
    public void EnableRope(bool enable)
    {
        if (cloth != null)
        {
            Destroy(cloth.gameObject);
        }

        enabled = enable;
        rigidbody.isKinematic = false;
        attached = false;

        rigidbody.useGravity = enable;
        rigidbody.velocity   = Vector3.zero;
        if (enable)
        {
            cloth  = ((GameObject)Instantiate(clothPrefab, pl.pos, Quaternion.identity));
            Cloth  = cloth.GetComponentInChildren <InteractiveCloth>();
            oldpos = pos = cloth.transform.Find("s2").position;
            Cloth.AttachToCollider(pl.RopeColl, false, false);
            Cloth.AttachToCollider(this.collider, false, true);
        }
    }