// Update is called once per frame void Update() { if (BolHelper.Distance(currentPlayer.gameObject, this.gameObject) < 0.3f) { this.gameObject.rigidbody.AddForce((currentPlayer.moveTarget - this.gameObject.transform.position).normalized * 15); } }
public void Pass() { this.gameObject.rigidbody.AddRelativeForce(BolHelper.CalculateBestThrowSpeed(this.gameObject.transform.position, currentPlayer.passTarget, 2) * currentPlayer.passPower, ForceMode.Impulse); //NOW THE BALL IS FACING THE DIRECTION OF SWIPE, ADD FORWARD FORCE SIMPLY }
void DoWalk() { if (subState == SubState.Init) { subState = SubState.Active; shootPower = 3; } if (subState == SubState.Active) { Debug.Log("HIT " + rayHit.collider.tag); isMove = true; moveTarget = rayHit.point + new Vector3(0.0f, 0.0f, 0.0f); if (rayHit.collider.tag == "Object") { Debug.Log("HIT OBJECT" + rayHit.collider.gameObject.name); currentObject = rayHit.collider.gameObject; playerState = PlayerState.Shoot; subState = SubState.Init; } else { cursor.gameObject.SetActive(true); cursor.gameObject.transform.position = moveTarget + new Vector3(0, 0.1f, 0); } if (isMove) { //transform.rotation = Quaternion.RotateTowards(transform.rotation,Quaternion.Euler(moveTarget), Time.deltaTime * 0.1f); if (haveBall) { agent.speed = speed * 1.5f; agent.destination = Ball.instance.gameObject.transform.position; } else { if (BolHelper.Distance(this.gameObject, Ball.instance.gameObject) < 0.5f) { haveBall = true; Ball.instance.currentPlayer = this; } agent.speed = speed; agent.destination = moveTarget; } distance = Vector3.Distance(transform.position, moveTarget); //if(agent.remainingDistance < 0.01f){ if (distance < 0.1f) { cursor.gameObject.SetActive(false); isMove = false; playerState = PlayerState.Idle; subState = SubState.Init; } } } if (subState == SubState.Deactive) { } if (subState == SubState.Finish) { } }