playMaker

Author Topic: Level restart problem [SOLVED]  (Read 4752 times)

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Level restart problem [SOLVED]
« 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?
« Last Edit: June 22, 2017, 05:29:21 PM by ItzArranT »

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Level restart problem
« Reply #1 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

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Level restart problem
« Reply #2 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.

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Level restart problem
« Reply #3 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

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Level restart problem
« Reply #4 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.

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Level restart problem
« Reply #5 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'

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Level restart problem
« Reply #6 on: June 18, 2017, 06:26:28 AM »
bump

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Level restart problem
« Reply #7 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!

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Level restart problem (another question for Jean)
« Reply #8 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.

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Level restart problem (another question for Jean)
« Reply #9 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

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Level restart problem [SOLVED]
« Reply #10 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