public void BeginThrowAnim(Vector3 passTarget, OffPlayer reciever, float arcType, float power) { if (!isRapidFire) { //todo cleanup this code, could cause bugs setting these values then running coroutine throwVector = passTarget; } targetOffPlayer = reciever; throwArc = arcType; throwPower = power; StartCoroutine("PassTheBall"); anim.SetTrigger("PassTrigger"); }
public void PassFootBallToMovingTarget(QB ballThrower, OffPlayer receiver, FootBall footBall, float arcType, float power) { isComplete = true; SetGameManager(); gameManager.AttemptPass(ballThrower, receiver, this, arcType, power); //todo, this is ugly. Probably should be a bool for isComplete if (rb == null) { rb = GetComponent <Rigidbody>(); } //targetPos = GetPositionIn(2, wr); transform.parent = null; rb.useGravity = true; BallisticMotion motion = GetComponent <BallisticMotion>(); Vector3 targetPos = receiver.transform.position; Vector3 diff = targetPos - transform.position; Vector3 diffGround = new Vector3(diff.x, 0f, diff.z); Vector3 fireVel, impactPos; Vector3 velocity = receiver.navMeshAgent.velocity; //FTS Calculations https://github.com/forrestthewoods/lib_fts/tree/master/projects/unity/ballistic_trajectory float gravity; if (Ballistics.solve_ballistic_arc_lateral(transform.position, power, targetPos + Vector3.up, velocity, arcType, out fireVel, out gravity, out impactPos)) { GameObject go = Instantiate(targetMarker, impactPos, Quaternion.LookRotation(ballThrower.transform.position + new Vector3(0, 1, 0))); go.name = "footballMarker"; go.transform.parent = FindObjectOfType <FootBall>().transform; Destroy(go, 2); transform.forward = diffGround; motion.Initialize(transform.position, gravity); motion.AddImpulse(fireVel); gameManager.ThrowTheBall(ballThrower, receiver, this, impactPos, arcType, power, isComplete); //todo the football stores whether the pass is complete or not, not sure if thats a good idea. } //Debug.Log("Firing at " + impactPos); }
public void AttemptPass(QB ballThrower, OffPlayer ballReciever, FootBall ball, float arcType, float power) { passAttempt(ballThrower, ballReciever, ball, arcType, power); }
public void ThrowTheBall(QB ballThrower, OffPlayer ballReciever, FootBall ball, Vector3 impactPos, float arcType, float power, bool isComplete) { onBallThrown(ballThrower, ballReciever, ball, impactPos, arcType, power, isComplete); }