private void ThrowHit(BalloonInfo bi) { hookedBalloon = bi; Vector3 dir = bi.transform.position - transform.position; float dist = dir.magnitude; Vector3 heading = dir / dist; float newDist = dist * HookMovePercentage.Value; targetPosition = transform.position + heading * newDist; otherTargetPosition = bi.transform.position - heading * newDist; startPosition = transform.position; otherStartPosition = bi.transform.position; startTime = Time.time; Destroy(hook); GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic; bi.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic; if (bi.GetComponent <BalloonAIStabbing>() != null) { bi.GetComponent <BalloonAIStabbing>().enabled = false; } }
private void PullBalloon() { float t = (Time.time - startTime) / HookMoveDuration.Value; if (t >= 1f) { GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; hookedBalloon.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; if (hookedBalloon.GetComponent <BalloonAIStabbing>() != null) { hookedBalloon.GetComponent <BalloonAIStabbing>().enabled = true; } hookedBalloon = null; hook = null; enabled = false; return; } transform.position = Vector3.Lerp(startPosition, targetPosition, t); hookedBalloon.transform.position = Vector3.Lerp(otherStartPosition, otherTargetPosition, t); }