playMaker

Author Topic: What am I doing wrong?  (Read 784 times)

megmaltese

  • Sr. Member
  • ****
  • Posts: 351
    • View Profile
What am I doing wrong?
« on: October 04, 2018, 01:26:05 PM »
I have an object CANVAS in the scene.
It's in the root.
I find an object called exactly "CANVAS" in the scene and store it in a variable.
Then, I activate that object.

WHAT CAN GO WRONG IN THESE TWO DAMN ACTIONS?

Playmaker is great but so so so so often it's so counterintuitive and convoluted it just brings to rip your hair from your head.

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 131
    • View Profile
Re: What am I doing wrong?
« Reply #1 on: October 04, 2018, 01:37:09 PM »
You're not saying what the problem is?
I would assume it doesn't activate the game object because the variable is empty when it tries. If this is the case, set it to "action sequence" to make sure it has found the game object and put it in the variable before trying to activate it.

https://hutonggames.fogbugz.com/default.asp?W1255

megmaltese

  • Sr. Member
  • ****
  • Posts: 351
    • View Profile
Re: What am I doing wrong?
« Reply #2 on: October 04, 2018, 09:44:45 PM »
Oh god, I didn't know about this action sequence thing, I thought it was ALREADY working like that... thank you for the hint, I'll activate this EVERYWHERE.

However, activated action sequence, still not working... and I swear that the object in the scene is named "CANVAS" and the string in the action is "CANVAS".
How is it possible that it doesn't find it?

megmaltese

  • Sr. Member
  • ****
  • Posts: 351
    • View Profile
Re: What am I doing wrong?
« Reply #3 on: October 04, 2018, 10:59:46 PM »
Maybe I found the problem... the CANVAS is DISABLED, and that's EXACTLY why I need to find it: to enable it!
And this action doesn't allow to include disabled objects!

The fun part about all this is that I disabled the canvas simply because I don't like to see it around while I am working on the scenery. Goddamnit!

Edit: maybe I found a workaround for this, even though I will have to manually add the CANVAS object to a FSM variable in each of my maps, which kind of defeats the "all automated" system I wanted to setup, but ok...

One curiosity: is it Unity that doesn't allow to find disabled GameObjects or this could be easily added to the Playmaker action?
« Last Edit: October 04, 2018, 11:14:35 PM by megmaltese »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
  • Official Playmaker Support
    • View Profile
Re: What am I doing wrong?
« Reply #4 on: October 04, 2018, 11:11:38 PM »
Hi,

yeah, it's important to understand what each action refers to and what Unity apis it uses. Find() ignores inactive objects

https://docs.unity3d.com/ScriptReference/GameObject.Find.html

you'll see it mentions that "This function only returns active GameObjects. "

 The other problem is that Finding object by name is slow in Unity, and so this is not recommended to begin with.

 What I would consider instead is  one of the following:

- maintaining a global variable, that an Fsm that knows about the canvas sets when it starts. You do that prior deactivating the canvas (https://hutonggames.com/playmakerforum/index.php?topic=1732.msg7589#msg7589)

- Have an Fsm on your canvas that fires a global Event when it starts, so that any FSM interested can listen to when the canvas will be activated.

- You don't deactivate the canvas, and instead you use CanvasGroup component, which allows you to hide it, and soft disable it, then it's alwasy active but not showing any content. https://docs.unity3d.com/Manual/class-CanvasGroup.html

Bye,

 Jean


megmaltese

  • Sr. Member
  • ****
  • Posts: 351
    • View Profile
Re: What am I doing wrong?
« Reply #5 on: October 04, 2018, 11:15:42 PM »
Thank you Jean!
Good to know that finding by name is slow.
However I only use this action at the start of the map to activate the CANVAS, then no more!

megmaltese

  • Sr. Member
  • ****
  • Posts: 351
    • View Profile
Re: What am I doing wrong?
« Reply #6 on: October 04, 2018, 11:30:20 PM »
What if I load the canvas calling it from a FSM?
Is it possible if the canvas is a prefab?
How do I add a GameObject to a scene? I can't find any action to do it.

Done it! CREATE OBJECT from the Ecosystem hurrah!!!
« Last Edit: October 04, 2018, 11:46:47 PM by megmaltese »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
  • Official Playmaker Support
    • View Profile
Re: What am I doing wrong?
« Reply #7 on: October 04, 2018, 11:38:51 PM »
Hi,

 Use the action CreateObject to add an object to a scene, can be a prefab or another object reference in the scene.

Bye,

 Jean

miguelfanclub

  • Full Member
  • ***
  • Posts: 152
    • View Profile
Re: What am I doing wrong?
« Reply #8 on: October 05, 2018, 03:31:18 AM »
What I do is I do all the finds I want from one game object (+50 objects at the moment) and then I just get them via get game object FSM when needed.

So I make sure I only find them once.