Hey Chris,
I am making a Customization menu and i am using UnityUI prefab, i have a custom script at the prefab that gets the current player with
player = AC.KickStarter.player.gameObject;
or with
player = FindObjectOfType().gameObject; (Which is a script with info on each Player)
I am calling this funtion from a custom Action List which is being called after I switch the Player but the result is a missing GameObject even though i print the proper player.
If I call the same function in update of the Menu prefab then i am getting the proper player each time.
Is there a delay from switching to one player to another and the call of my action that could result to a missing gameobject maybe...?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Try inserting an Engine: Wait Action of -1 second to delay the next Action by a single frame.
However, the best way to react to a change in Player character is to rely on the OnSetPlayer custom event. This event will be fired once a new Player has been spawned and set up, and also passes the new Player as a parameter, i.e.:
This would be placed in the scene inside a regular MonoBehaviour script, rather than a custom Action.
Thanks Chris, it works better now.