Beispiel #1
0
    void PushForceShape()
    {
        if (select == null)
        {
            if (Input.GetMouseButtonDown(0))
            {
                ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint);
                if (shapes.Length <= 0)
                {
                    return;
                }

                select = shapes[0];
            }
        }
        else
        {
            mouseOffset = mousePoint - select.Position;

            text.text = mouseOffset.magnitude.ToString();
            text.transform.position = mousePoint;
            Debug.DrawLine(select.Position, mousePoint);

            if (Input.GetMouseButtonUp(0))
            {
                select.AddForce(-mouseOffset);
                select = null;
            }
        }
    }