playMaker

Author Topic: [SOLVED] Gameobject not found on scene load  (Read 3158 times)

michaelgenn

  • Playmaker Newbie
  • *
  • Posts: 7
  • GenPhi Games
[SOLVED] Gameobject not found on scene load
« on: February 01, 2016, 02:37:12 PM »
Hi,

I am having an issue were when I load the scene initially (I'm on the scene and press play), the spawned gameobject is found but when I reload the scene or call the scene from a different scene it can't find the spawned gameobject. 

Maybe to help clarify...
I'm using find with tag and iTweenMoveUpdate to move towards the spawned gameobject.  Pressing play on the scene initially, the spawned gameobject is found and the FSM gameobject starts moving toward the spawned gameobject.  When I reload or call from a different scene, the spawned gameobject isn't found so there is no movement toward the spawned gameobject.

I've tried setting the script order to load my spawn script before playmaker to see if that works... It's not making sense to me why it's able to find it when I just play the scene but not when I call the scene while in-game.

Probably something simple but I'm stumped...

Here's the error I get in Unity but I'm sure it's due to the missing gameobject...

NullReferenceException: Object reference not set to an instance of an object
HutongGames.PlayMaker.Actions.iTweenMoveUpdate.OnUpdate () (at Assets/PlayMaker/Actions/iTween/iTweenMoveUpdate.cs:102)
HutongGames.PlayMaker.FsmState.OnUpdate () (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:255)
HutongGames.PlayMaker.Fsm

Thanks in advance!
« Last Edit: February 02, 2016, 12:43:17 PM by michaelgenn »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Gameobject not found on scene load
« Reply #1 on: February 02, 2016, 12:44:38 AM »
How are you setting the Transform Position variable?
Is it set by another FSM?

If multiple FSMs update in the same frame you can not guarantee the order in which they are updated. Maybe the variable is not set when you run iTweenMoveUpdate. Try delaying the tween by a frame using a Next Frame Event or use Is GameObject Null to wait until the variable is set.
 

michaelgenn

  • Playmaker Newbie
  • *
  • Posts: 7
  • GenPhi Games
Re: Gameobject not found on scene load
« Reply #2 on: February 02, 2016, 12:42:20 PM »
Thank you for the reply!  I used the Is GameObject Null to wait and it works like a charm!!

Thanks again Alex!