playMaker

Author Topic: Loosing game object reference  (Read 1831 times)

Hexkonst

  • Playmaker Newbie
  • *
  • Posts: 9
Loosing game object reference
« on: April 01, 2018, 03:17:37 PM »
I'm trying to create a projectile from a firepoint gameobject that is a child of the weapon.

* Event1
Find Game Object and store to "Firepoint"
* Event2
Create object at "Firepoint"

It stores the reference correctly the first time you play test it, but the second play through the reference is lost and the bullet is spawned from 0,0,0.

Any ideas what's going on?

Thank you!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Loosing game object reference
« Reply #1 on: April 02, 2018, 03:14:36 AM »
Hi,

 are you trying to reference of an instance in the scene instead of a prefab on the assets folder and in between load a new scene or something? usually reference are getting lost because of this.

 Bye,

 Jean

Hexkonst

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Loosing game object reference
« Reply #2 on: April 02, 2018, 06:05:23 AM »
Hi,

 are you trying to reference of an instance in the scene instead of a prefab on the assets folder and in between load a new scene or something? usually reference are getting lost because of this.

 Bye,

 Jean

Thank you for the swift answer! :)

I know this limitation of the Unity engine - however, that shouldn't be the case if I use the "Find Game Object" to update the correct reference each play session (if I'm not mistaken). It seems as if the reference is made, but to the old session cached object instead. I'm starting to suspect a bug.

I'm using "Find Child" instead and "Set Game Object" to a global variable. Which seems to solve the problem, but it's still mildly unsettling. :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Loosing game object reference
« Reply #3 on: April 03, 2018, 03:10:15 AM »
Hi,

 uhm, maybe you are not waiting for the scene to be loaded properly? waiting a frame might help, are you listening to the callback from the SceneManager for when a sceen is ready?

Bye,

 Jean