// Update is called once per frame void Update() { if (mouseQuery.ClickedBody != null) { // Attach with mouse joint if (mouseJoint == null) { mouseJoint = gameObject.AddComponent <LPJointMouse>(); mouseJoint.BodyA = mouseQuery.ClickedBody.gameObject; mouseJoint.BodyB = mouseQuery.ClickedBody.gameObject; mouseJoint.MaximumForce = 500; mouseJoint.Initialise(lpMan); } bool aTouch = false; Vector3 touchPos = new Vector3(); InputUtilities.GetMouseInput(out aTouch, out touchPos); if (aTouch) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(touchPos); mouseJoint.SetTarget(mousePos); } } else { TryDeleteMouseJoint(); } }
// Update is called once per frame void Update() { bool aTouch = false; Vector3 touchPos = new Vector3(); InputUtilities.GetMouseInput(out aTouch, out touchPos); if (aTouch) { if (ClickedBody == null) // If we have not clicked on a body yet { Vector3 mousePos = touchPos; mousePos = Camera.main.ScreenToWorldPoint(mousePos); ClickedBody = lpMan.TestPointForBody(mousePos.x, mousePos.y); } } else { ClickedBody = null; } }