Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: ItzArranT on June 09, 2017, 01:35:18 PM

Title: Level restart problem [SOLVED]
Post by: ItzArranT on June 09, 2017, 01:35:18 PM
I'm currently trying to make my game restart the same level (Scene) upon its loss condition being met.

The loss State is reached fine and I'm trying to use the 'Restart Level' action to reload the level and let the Player try again.  However, while the scene does appear to restart, the lighting looks different, the controls no longer respond and I get the following error:

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

Any ideas on what I'm doing wrong?
Title: Re: Level restart problem
Post by: Ofonna on June 09, 2017, 08:49:56 PM
in the beginning of you're scene you seem to be trying to access an object you have already destroyed , in normal script you check if its null, if null return

however this seems like a weird problem, because everything gets destroyed on scene load, so check all your dealings with game objects
Title: Re: Level restart problem
Post by: ItzArranT on June 11, 2017, 03:10:50 PM
Thanks Carmichael, I'll take a look and see if I can find anything, although I have no idea which game object could possibly be the problem.

Could it be that I'm not getting or setting something?

It might also be worth mentioning- in case it helps- that prior to the 'Restart Level' action I have included a 'Camera Fade Out' action, which seems to be completely ignored upon the "Level loss" condition being met.
Title: Re: Level restart problem
Post by: Ofonna on June 11, 2017, 07:00:21 PM
you can disable the camera fade out action and test it out, i dont use that action as i manually create it myself, using a panel and easing or curving the alfa float can get the job done for you.

and yes you are probable getting a gameobject on start before the object is created,
set property wouldn't give you that error except that reference has been completely rremoved
Title: Re: Level restart problem
Post by: ItzArranT on June 12, 2017, 03:02:27 PM
Hey Carmicheal, I think we might be getting somewhere after your last reply- which I really appreciate.

You're right, there are two game objects I am telling the game to get on start: I use 'Get Owner' on both the Game Manager game object and Level Manager game object- so I can store them as global variables.

Assuming I stick with store them as global variables, any ideas how I could get around the problem I'm having now? As you say, if I am indeed getting a gameobject on start before the object is created.
Title: Re: Level restart problem
Post by: ItzArranT on June 13, 2017, 10:50:25 AM
I'm convinced I'm simply not doing something which I should typically do with Playmaker when using 'Get Owner' and 'Restart Level'
Title: Re: Level restart problem
Post by: ItzArranT on June 18, 2017, 06:26:28 AM
bump
Title: Re: Level restart problem
Post by: ItzArranT on June 21, 2017, 07:36:55 AM
Still really need some help with this- I'm so confused why this keeps happening.

Any help would be hugely appreciated!
Title: Re: Level restart problem (another question for Jean)
Post by: terri on June 22, 2017, 05:57:53 AM
You could be trying to access a GameObject global variable in a FSM before it is actually assigned on another FSM.

One way to get around this is to use "Check if GameObject is null". Check everyframe and only start running the logic once it returns false.

I'm not sure why this would happen only on scene restarts but its possible, and overall a good practice anyways. Obviously its only relevant when the GameObject is active from scene start and trying to access the variable on its initial state.
Title: Re: Level restart problem (another question for Jean)
Post by: Ofonna on June 22, 2017, 06:18:32 AM
hi, i didn't see your reply......what's the latest problem? there are several ways to solve this, i'd just like to know what your exact issue is
Title: Re: Level restart problem [SOLVED]
Post by: ItzArranT on June 22, 2017, 05:29:08 PM
Hey all,

Problem solved! I played around with a few of the FSMs and something seems to have fixed itself. 

Thanks so much for all the help and input.  I'm aiming to make my first ever complete game with Playmaker so I'm sure you'll be hearing plenty more from me on the forums ;)

Thanks again