private void UpdateLoading() { Vector3 mpos = HandController.ConstrainedMousePos(); Vector3 mvpos = _mainCamera.ScreenToViewportPoint(mpos); mvpos.x = mvpos.x * 2f - 1f; mvpos.y = mvpos.y * 2f - 1f; Vector3 vpos = LoadViewPoint; vpos.z = mvpos.z; if (Input.GetMouseButton(0) && Vector3.Distance(mvpos, LoadViewPoint) < LoadViewRadius) { OnShotLoaded(); } Vector3 finalPosition = GetFinalPosition(); _grabbedObject.transform.position = finalPosition; if (Input.GetMouseButtonUp(0)) { Vector3 fallPos = finalPosition; fallPos.y = 0f; _grabbedObject.GetComponent <Launchable>().Launch(fallPos, 0f); _grabbedObject = null; _state = State.NothingGrabbed; TargetObject.SetActive(false); return; } }
private Vector3 GetFinalPosition() { Vector3 mpos = HandController.ConstrainedMousePos(); Vector3 curPosition = Camera.main.ScreenToWorldPoint(new Vector3(mpos.x, mpos.y, _initialMousePosition.z)); curPosition.x *= 0.8f; curPosition.y *= 0.9f; curPosition.y += 0.2f; return(curPosition); }
private void UpdateNothingGrabbed() { Vector3 mpos = HandController.ConstrainedMousePos(); Vector3 mvpos = _mainCamera.ScreenToViewportPoint(mpos); mvpos.x = mvpos.x * 2f - 1f; mvpos.y = mvpos.y * 2f - 1f; Vector3 vpos = LoadViewPoint; vpos.z = mvpos.z; if (Input.GetMouseButtonDown(0) && Vector3.Distance(mvpos, GrabViewPoint) < GrabViewRadius) { if (OnLetterGrabbed != null) { OnLetterGrabbed(); } OnThingGrabbed(Instantiate(BallPrefab)); } }