x


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;
}
more ▼

asked Nov 12 '10 at 06:28 PM

Om3n 2 gravatar image

Om3n 2
16 1 2 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Nov 12 '10 at 06:48 PM

Loius gravatar image

Loius
10.5k 1 11 41

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 coming 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...

Nov 12 '10 at 11:17 PM Om3n 2
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2483
x2075
x227

asked: Nov 12 '10 at 06:28 PM

Seen: 431 times

Last Updated: Nov 12 '10 at 06:28 PM