void Update() { updateMousePosition(); if (interactor.hasObjectGrabbed() && isActionLaunch()) { interactor.launchGrabbedObject(currentVelocity * launchMultiplicator + Vector3.up * launchUpMultiplicator, launchAngularVelocity); } if (isActionGrab()) { Interactable obj = returnPointedInteractable(); if (obj != null) { interactor.addGrabbedObject(obj); } else { StartZone diceZone = returnPointedZone(); if (diceZone != null && diceZone.dice != null && diceZone.dice.isGrabbable()) { interactor.addGrabbedObject(diceZone.dice); } } return; } interactor.influenceLastLaunchedObject(Vector3.Scale(new Vector3(1f, 0f, 1f), currentVelocity) * postLaunchFactorControl, postLaunchTimeInfluence); }
StartZone returnPointedZone() { StartZone r = null; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray, 100, layerInteractable, QueryTriggerInteraction.Collide); foreach (var item in hits) { r = item.collider.gameObject.GetComponent <StartZone>(); if (r != null) { return(r); } } return(null); }