void CastFireball() { Vector3 fireballPosition = _pointBetween; float intermediateRightValue = RightSpellController.FirePercentageCharged * .5f; float intermediateLeftValue = (LeftSpellController.FirePercentageCharged * .5f) * -1; float delta = intermediateRightValue + intermediateLeftValue + .5f; Vector3 leftUp = LeftController.transform.rotation * Vector3.up; Vector3 rightUp = RightController.transform.rotation * Vector3.up; fireballPosition = Vector3.Lerp(LeftController.transform.position - leftUp * (.05f + _castFireball.Size) + -LeftController.transform.right * .07f, RightController.transform.position - rightUp * (.05f + _castFireball.Size) + RightController.transform.right * .07f, delta); _castFireball.FollowTarget(fireballPosition); float distance = Vector3.Distance(RightController.Hand.transform.position, LeftController.Hand.transform.position); distance = Mathf.Clamp(distance - _fireballHandOffset, 0, _fireballMaxSize); if (RightSpellController.HandState == HandState.Fire && LeftSpellController.HandState == HandState.Fire) { float newSize = _castFireball.Size; if (_castFireball.Size < distance) { newSize = _castFireball.Size += Mathf.Clamp(Time.deltaTime * 0.1f, 0, distance); } if (_castFireball.Size > distance) { newSize = distance; } _castFireball.Size = newSize; } }
void ControlFireball() { // Set target position Vector3 fireballPosition = vrPlayer.LeftHand.DesiredFireballPosition + (vrPlayer.RightHand.DesiredFireballPosition - vrPlayer.LeftHand.DesiredFireballPosition) * .5f; _largeFireball.FollowTarget(fireballPosition); // Set target size ControlFireballSize(); }