- Home /
Trouble with collisions
Im having some issues with collision... for some reason i cannot assign value to blocks smashed from outside Score() Ive tried doing something before its called so i can assign a score value to blocks destroyed but the if statement doesn't seem to be called at all where a variation of it in the Score() function seems to give an error about += instead of :... Any advice or input would be greatly appreciated. Im a fairly new programmer on and off over the years.
function OnCollisionEnter(collision : Collision) { // Rotate the object so that the y-axis faces along the normal of the surface var contact = collision.contacts[0]; var rot = Quaternion.FromToRotation(Vector3.up, contact.normal); var pos = contact.point; Debug.Log("testing"); if(collision.gameObject.tag == "10Block") { ScoreKeeping.Score +=10; Destroy (gameObject); }
//score();
//Debug.Log Score;
}
function score(){
if(collision.gameObject.tag == "10Block");{
ScoreKeeping.Score +=50;
Debug.Log (ScoreKeeping.Score);
}
return; }
Answer by Loius · Nov 12, 2010 at 06:48 PM
Remove the semicolon from the if line in the score function; you essentially have an if statement that does nothing followed by a code block.
Yea i had been hacking at that file for some time... was starting to get ugly.. I found the problem though with some insight from a friend. I ran a debug to get the tagt on the object and it was co$$anonymous$$g back untagged. The issue was the if statement itself needed to remove collision. from it. Seems simple enough wish i was able to see it easier. ty anyways...