What exactly is it that you think detects the end of the level? I see all of the obstacle GameObjects, if I click on the highest numbered one (28) to try and get to where this level should end, I don’t see anything else in that area that would indicate some form of trigger collider or similar? Am I missing something?
Oh hang on, its something to do with the canvas isn’t it… bear with me…
I think this is your problem. You have your end GameObject as a child of the canvas. The canvas is being drawn to the camera, as such I don’t think you’ll ever actually reach it, because you can’t “touch” it so to speak.
Updated Sat Sep 29 2018 22:31
Ok, give this a go;
- create a new empty GameObject in the Hierarchy in Level 1
- set its Transform to 0, 3, 100. Rotation 0, 0, 0. Scale 1, 1, 1
- name it “End”
- add a Box Collider to it
- tick the Is Trigger property of the Box Collider component
- add your EndTrigger.cs script as a component
- select all of your obstacle GameObjects and disable them (makes testing easier)
- run the game
Your ball will now roll all the way along the track, hits the trigger, displays a message, loads the next scene.
To then tidy up, I’d suggest removing the “end” GameObject you have from the canvas. You also have an “end1”, not sure what that is, I didn’t check it out but if you don’t need it, get rid of it.
Don’t forget to re-enable all of your obstacles and save the scene.
You would then need to add a copy of the new end GameObject in the relevant location in each level.
Alternatively… if the only way to get a score is by travelling along the road, then you know that if they get a score of 99+ they have reached the end of the first level. You could remove the collider altogether and base progression purely on their accumulated score. Just a thought.
Hope this helps