FindObjectOfType not working

Hi, when I edited the script as in the video and tried to play instead of going from the start scene to level 01 and to the win screen when the ball falls out of the playspace, I click start game and get a brief glimpse (about .5 seconds) of level 01 before it switches to the win scene. I thought I copied everything exactly, so not really sure what to try. Included is screenshot of my script and unity screen. I am using Unity version 5.3.5

I believe what might be the problem is that the script isn’t linked on the LevelManager in the second scene.

Select LevelManager object in the hierarchy and check that the LevelManager script is attached. If not, drag and drop the script on.

Check that when you moved your LoseCollider box up to fill in the holes, that you didn’t put it in contact with your other colliders. That will cause a constant collision and take you right to your Win Screen.

So move your LoseCollider down just a bit and you should be good to go, if that’s the issue.

1 Like

Try to put FindObjectOfType method into Start function.
FindObjectOfType function is very slow and that maybe your problem.

I know it has been awhile however if you want the level manager to work with a unity version like 5.4.1 You seem to need a void before it for example I got it to work with:
void Awake(){
levelmanager = GameObject.FindObjectOfType ();

The ball script works because it is in a void start. Odd that a newer version has moved to that but it sounds like there are better ways to do this sort of thing anyways with tags when I went looking for a solution (posted here.

i have the same problem i able to solve it by dragging the loose collider a little down…

Is it solved then?

@Nechama_R hasn’t visited the forums since the 5th September…

1 Like

Thank you this solved it!

1 Like

Privacy & Terms