void OnCollisionEnter(Collision col)//attach ball on collision with player with ball { if (col.gameObject.transform.Find("Shooting") && col.gameObject.GetComponent <Full_train_nn>().hasBall&& col.gameObject.GetComponent <Full_train_nn>().team != team || col.gameObject.tag.Equals("shot")) { GetComponent <Rigidbody>().velocity = new Vector3(0, GetComponent <Rigidbody>().velocity.y, 0); GetComponent <Rigidbody>().angularVelocity = Vector3.zero; if (timer <= 0) { AddReward(.2f * ballTouch); gc.changePlayerWithBall(this); timer = 1f; hasBall = true; } } }