- Home /
Football goal script
I made this script for a game just like head soccer: http://www.youtube.com/watch?v=wC7421whHfc
When the ball goes in the net it puts 1+ on the variable. i havent done the other stuff that it needs to do. But the script does not work.
var Goals : int = 0;
function OnCollisionEnter(other: Collision) {
if(other.Tag=="Goal"){
Goals=Goals+1;
}
}
Answer by tanoshimi · Nov 21, 2013 at 05:29 PM
Should it not be:
if(other.gameObject.Tag=="Goal"){
...
}
?
If that still doesn't work, check that the OnCollisionEnter() function itself is being called. If not - is this script attached to the ball? Do you also have a rigidbody attached to the ball? Is there a collider on the goal and is it tagged "Goal"?
It still does not work with the modify script, and i did all the things you said.
So "does not work" = the collision is not detected, or the "Goal" tag does not match?