Esempio n. 1
0
    static int AddForceAtPosition(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 4)
        {
            InteractiveCloth obj  = LuaScriptMgr.GetNetObject <InteractiveCloth>(L, 1);
            Vector3          arg0 = LuaScriptMgr.GetNetObject <Vector3>(L, 2);
            Vector3          arg1 = LuaScriptMgr.GetNetObject <Vector3>(L, 3);
            float            arg2 = (float)LuaScriptMgr.GetNumber(L, 4);
            obj.AddForceAtPosition(arg0, arg1, arg2);
            return(0);
        }
        else if (count == 5)
        {
            InteractiveCloth obj  = LuaScriptMgr.GetNetObject <InteractiveCloth>(L, 1);
            Vector3          arg0 = LuaScriptMgr.GetNetObject <Vector3>(L, 2);
            Vector3          arg1 = LuaScriptMgr.GetNetObject <Vector3>(L, 3);
            float            arg2 = (float)LuaScriptMgr.GetNumber(L, 4);
            ForceMode        arg3 = LuaScriptMgr.GetNetObject <ForceMode>(L, 5);
            obj.AddForceAtPosition(arg0, arg1, arg2, arg3);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: InteractiveCloth.AddForceAtPosition");
        }

        return(0);
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //HandleInput ();

        cloth.AddForceAtPosition(new Vector3(2, 0, 0),
                                 new Vector3(0.1f, 0.1f, 0),
                                 0.1f);

        Debug.Log(cloth);
    }
Esempio n. 3
0
    void HandleInput()
    {
        for (var i = 0; i < Input.touchCount; i++)
        {
            Touch touch = Input.GetTouch(i);
            if (touch.phase == TouchPhase.Began)
            {
                ((InteractiveCloth)this.GetComponent <InteractiveCloth>()).AddForceAtPosition(new Vector3(0, 0, 20),
                                                                                              new Vector3(touch.position.x, touch.position.y, 0),
                                                                                              0.1f);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log(SackBehavior.Kicks);
            ((InteractiveCloth)GetComponent <InteractiveCloth>()).AddForceAtPosition(new Vector3(0, 0, -5),
                                                                                     new Vector3(2, 2, 0),
                                                                                     1.0f);

            Debug.Log(GetComponent <InteractiveCloth>());
        }

        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log("Mouse down");
            Ray        ray = Camera.main.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                Debug.Log("hit some object");
                if (hit.collider == gameObject.collider)
                {
                    Debug.Log("Hit this object: " + hit.point);
                    InteractiveCloth cloth = GetComponent <InteractiveCloth>();
                    Debug.Log("Cloth = " + cloth);
                    // Gets here, and cloth variable is a valid InteractiveCloth (there is only one in the scene)
                    // hit.point looks to be exactly where the ray should intercept the cloth
                    cloth.AddForceAtPosition(new Vector3(0, 0, 20), hit.point, 5);
                    Debug.Log("Done applying force.");
                }
            }
        }
    }