private void OnTriggerEnter(Collider collider) { BallBehavior script = collider.GetComponent <BallBehavior>(); if (script != null) { script.OnShot(this.team, this.flag, ballsColorDuration); Vector3 movement = collider.transform.position - this.transform.position; movement.Normalize(); if (dashing) { movement *= ballDashForce; } else { movement *= ballForce; } collider.GetComponent <Rigidbody>().AddForce(movement); } if (collider.tag == "Player") { Vector3 movement = collider.transform.position - this.transform.position; movement.Normalize(); if (dashing) { movement *= playerDashForce; } else { movement *= playerForce; } collider.GetComponent <Rigidbody>().AddForce(movement); } }