public void Serve() { Vector3 currentPosition = transform.position; BallLogic ball = BallLogic.Instance; ball.AppearBall(new Vector3(currentPosition.x + 0.1f, 4.05f, currentPosition.z), Vector3.zero); Vector3 ballVelocity = ball.GetVelocity(_serveTarget, 1.5f); ball.GetComponent <Rigidbody>().velocity = ballVelocity; BallLogic.Instance.SetHittingPlayer(_id); Destroy(_animatedServingBall); }
private void Serve() { Vector3 currentPosition = transform.position; BallLogic ball = BallLogic.Instance; ball.AppearBall(new Vector3(currentPosition.x + 0.1f, 4.05f, currentPosition.z), Vector3.zero); float minTime = GetServeMinTime(); float maxTime = GetServeMaxTime(); float time = GetTimeToBounce(minTime, maxTime); Vector3 velocity = BallLogic.Instance.GetVelocity(aimTarget.position, time); ball.GetComponent <Rigidbody>().velocity = velocity; BallLogic.Instance.SetHittingPlayer(_id); Destroy(_animatedServingBall); }