c# - Why isn't collision working properly? And why won't it load the next level? -


this college assignment, aim follows:

for first level: collect 3 objects in 30 seconds. second level: collect many objects possible in 90 seconds.

i have made first level mostly, , collision working, wouldn't load next level upon completion reason.

here code generates objects, can't figure out how make appear here, i'm using screenshot instead.

objectgeneratorscript pt 1

objectgeneratorscript pt 2

this has worked @ college, reason isn't @ home , it's stressing me out assignment due in 2 days , genuinely can't see waht isn't working. didn't change either since worked @ college.

using unityengine; using system.collections;  public class objectgeneratorscript : monobehaviour { public static int points; float radians(float degrees) {     return (degrees / 180) * mathf.pi; } void makeobjects(float mindistancefromoriginal, float maxdistancefromorigin, primitivetype objtype, int number, string tag) {     //setting material variables     material cubematerial;     material spherematerial;     material cylindermaterial;     float angle;     float distancefromorigin;     float x;     int i;     float z;     gameobject temp;     //telling code load material variables     cubematerial = resources.load("cubematerial", typeof(material)) material;     spherematerial = resources.load("spherematerial", typeof(material)) material;     cylindermaterial = resources.load ("cylindermaterial", typeof(material)) material;     (i=1; i<=number; i++) {         distancefromorigin = mindistancefromoriginal + random.value * (maxdistancefromorigin - mindistancefromoriginal);         angle = random.range (0, 360);         x = distancefromorigin * mathf.cos (radians (angle));         z = distancefromorigin * mathf.sin (radians (angle));         temp = gameobject.createprimitive (objtype);         temp.transform.position = new vector3 (x, 0.5f, z);         renderer rend = temp.getcomponent<renderer>();          //if functions tell game load material when object generated         if (tag=="cube"){rend.material = cubematerial;}         if (tag=="sphere"){rend.material = spherematerial;}         if (tag=="cylinder"){rend.material = cylindermaterial;}     } } // use initialization void start () {       }   // update called once per frame void update () {     print (objectgeneratorscript.points);     if (objectgeneratorscript.points == 6)      {         application.loadlevel ("lvl2");     } }  void oncollisionenter (collision col) {     if (col.gameobject.tag == "cube") {         destroy (col.gameobject);         objectgeneratorscript.points = objectgeneratorscript.points + 1;     }     if (col.gameobject.tag == "sphere") {         destroy (col.gameobject);         objectgeneratorscript.points = objectgeneratorscript.points + 2;     }     if (col.gameobject.tag == "cylinder") {         destroy (col.gameobject);         objectgeneratorscript.points = objectgeneratorscript.points + 3;     } } 

}


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo