Player colliding with Ball problem.

So I made a sphere and I am trying to check if I am colliding with this sphere. I am using this code

function BallControllerColliderHit(hit : ControllerColliderHit)

{
if(hit.gameObject.name == “dodgeball”)
{
hit.gameObject.animation.Play(“ball_spin”);
}

}

Pretty much does not work. The animation works because I have it play automatically and it spins my ball, so thats not the problem. I have attached this script to my player which was a “First Person Controller” but it is not working. I have also used print(“Collided with Ball”); in place of the animation and that did not work either but I can not think of anything wrong with the conditions… And the sphere is tagged “dodgeball” correctly.

You need to use OnControllerColliderHit , rather than BallControllerColliderHit --- you also say you "tagged" the sphere as dodgeball, but in your code you check to see if it's "named" dodgeball, you need to check the "tag" if that's what you're meaning to check, not the name.