playMaker

Author Topic: [SOLVED] Finding GameObject and waiting for invisible  (Read 6985 times)

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
[SOLVED] Finding GameObject and waiting for invisible
« on: August 14, 2016, 09:53:09 PM »
I am trying to find a GameObject and wait for it to become invisible before continuing. This FSM can not placed on the object that is disappearing. I tried to make this state call itself if visible, or another visibility check state which then calls back or to the next state, but nothing has worked for me. Checking "Every Frame" on the visibility check event does nothing. The "Show Story" state if finding the item who should dissapear and storing it in guiBackPanel.



How can I wait for a GameObject to become invisible? I am using PlayMaker 1.8.2.f7.
« Last Edit: September 02, 2016, 10:48:14 AM by Gatsu »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Finding GameObject and waiting for invisible
« Reply #1 on: August 18, 2016, 08:58:38 AM »
Can you think of another way to do what you are trying to do? Do you need to wait for another character to go off screen so you can continue moving?
Available for Playmaker work

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Finding GameObject and waiting for invisible
« Reply #2 on: August 18, 2016, 09:34:38 AM »
Hi,
How are you making the Gameobject invisible?

If for example you are using an alpha you could get that value and do a float compare.

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Finding GameObject and waiting for invisible
« Reply #3 on: August 18, 2016, 05:37:42 PM »
I have an indestructable message box that becomes active every level started. When I click a button in that box it goes away by getting inactive, and that is when I want the FSM to move passed the point that I have in the screenshot.

All I need is any way to make the FSM start running after that message boxes disable button has been pressed without adding an FSM to that button or even the message box.
« Last Edit: August 18, 2016, 05:48:18 PM by Gatsu »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Finding GameObject and waiting for invisible
« Reply #4 on: August 19, 2016, 06:31:35 AM »
Hi, There is a custom action on the Ecosystem called "is active" you could use that to check if the object is active or not (turn on every frame)

But it would be better to use a send event when possible
or if the button is in unityUI then you can use the U Gui Component proxy (you can have more that 1 on a button)
and connect it to the fsm.

The reason is that every frame uses a lot more resource (cpu/ram) than a single send event when pressed, if there are just a few objects its fine but when you get more items it can become a problem :)

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Finding GameObject and waiting for invisible
« Reply #5 on: August 20, 2016, 08:30:40 AM »
Thank you, I didnt know about the ecosystem that is pretty cool.

What did not work: using the u GUI button on click event, it just doesn't move on from that point.

What did not work:

I get the UI object here (I added a "Wait" to make sure the GameObject can be found after "ShowStory" has been called):


and then I look if its active here:



I'm forever stuck on the "Story screen check". It seems like playmaker is running all its actions within a state async. I think I need the ShowStory call to finish before I can find the GameObjects I need. I can't possibly be the only person with this timing problem, so is there a way to wait for a method call to finish without using the unreliable "Wait"? Or I need something like the "Find Game Object" to run every frame until one is found (this is why I were using the visibility search earlier).
« Last Edit: August 20, 2016, 09:47:57 AM by Gatsu »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Finding GameObject and waiting for invisible
« Reply #6 on: August 20, 2016, 10:22:21 AM »
Hi,
Have you added the Playmaker Ugui prefab in your scene?

Here is a introduction video for the ugui proxy :


you have to get the ugui proxy full from the Ecosystem

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Finding GameObject and waiting for invisible
« Reply #7 on: August 20, 2016, 10:49:39 AM »
Well, this guy is adding his actions ON the actual button and since I have a button that survives throughout the entire game session, I don't want to add a behavior on to it which only has a use in one of the 100 scenes. I want this behavior of the button to be specific for this scene. This is what I mean with "This FSM can not be placed on the object that is disappearing". I am saying here that I can not place any FSM on the actual button. So, my problem which is about finding a GameObject that starts as inactive still persists. I need to ether call the "ShowStory" and "Find Game Object" in a truly synchronous way or wait for my clickable button to be active and then after it is certain that the button is active, use the "Find Game Object" in combination with the "U Gui Button On Click Event".

Another way to do it would be to actually be able to call a non-static method and store it's returned value somewhere since I do have methods for finding this inactive GameObject but neither can I find an action which will call a non-static method and store it's value.

PlayMaker is starting to make me think of JavaScript web development but without any control at all ;D Also, the link you posted is just one of those tutorials extremely hard to follow due to strong accent, mumbling and with such low image quality that it's just barely readable. That along with the fact that he's just rushing through it explaining basically nothing, as far as I know. I have watched it 3 times and I haven't learned anything.
« Last Edit: August 20, 2016, 11:35:14 AM by Gatsu »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Finding GameObject and waiting for invisible
« Reply #8 on: August 20, 2016, 12:49:12 PM »
Hi,
the button proxy can be connected to any fsm and also the event can be changed.
in the ugui component proxy change the bottom target :
Click on owner and change to game object then drag on the object with the fsm.
if you want to change the event name to trigger click on edit.

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Finding GameObject and waiting for invisible
« Reply #9 on: August 20, 2016, 01:03:44 PM »
Then how do I drag a GameObject from the editor to the action that does not exist in the editor? It's not possible. It's a GameObject that came from the previous scene, an indestructable GameObject that survives scene transitions which is the button to make my FSM continue. It is not visible in the editor in the scene that I will be using it. It needs to be found by the FSM which IS part of that scene.

It's like this, trying to explain it more clear what my problem is:

  • I have an FSM that exists on a scene.
  • I have an inactive GameObject (a button) withch is created on scene load, it does not exist before that.
  • This GameObject (my button) then gets activated by a method call from my FSM (the "ShowStory" call).
  • I need my FSM to find that GameObject (the button again) after it has been created and activated.

It's on point 4 that I am having problems. How do I wait for that GameObject to have been created and activated?
« Last Edit: August 20, 2016, 01:26:18 PM by Gatsu »

cwmanley

  • Full Member
  • ***
  • Posts: 107
Re: Finding GameObject and waiting for invisible
« Reply #10 on: August 20, 2016, 02:28:37 PM »
You can use Global Variables.
https://hutonggames.fogbugz.com/default.asp?W641

or,

The No Exit Sample Has a Example on using Global Events.
https://hutonggames.fogbugz.com/default.asp?W209

Also, the Get Event Info Actions is very helpful.

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Finding GameObject and waiting for invisible
« Reply #11 on: August 20, 2016, 06:01:48 PM »
I don't see how using a global variable will help me actually find the GameObject I'm searching for to be able to store it in a variable?

Am I really that unclear with my problem that nobody can understand? I really don't know how to explain it more clearly. Or is it me not understanding how any of your solutions given would help me? I'm sorry if my brain is a bit slow.

Let me try again in another way of saying it:

State 1:
Activate GameObject with method call which has reference to inactive GameObjects.
[transitions to state 2]

State 2:
Wait for State 1's method call to finish running so I can get a reference to the newly activated GameObject and store it in eather a local or a global variable. Let's say we store that GameObject in the "ActiveObject" variable.
[transitions to state 3]

State 3:
Detect click on stored "ActiveObject" (local or global variable does not matter) which is a button.
[transitions to state 4]

State 4:
Do anything, what happens in this state does not matter.
[end]

In this scenario it is State 2 that is the problem. How do I wait for State 1 to finish? For example, I would like to keep searching for a GameObject by tag until it was found and not continue the FSM until I've found one.
« Last Edit: August 20, 2016, 06:20:18 PM by Gatsu »

cwmanley

  • Full Member
  • ***
  • Posts: 107
Re: Finding GameObject and waiting for invisible
« Reply #12 on: August 20, 2016, 06:20:31 PM »
I' m sorry if I do not understand. I have ready the post many times  :(

When you create this "object that cannot have a Fsm" at load can you add it to a global variable?

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Finding GameObject and waiting for invisible
« Reply #13 on: August 20, 2016, 08:11:43 PM »
But if I did put that GameObject in a global variable, how would my other FSM wait for that global variable to contain the GameObject?

Can't we call a non-static method and store its returned value somehow? And then only move to the next state once that has finished? That way I can get the GameObject that I need.
« Last Edit: August 20, 2016, 08:26:16 PM by Gatsu »

Gatsu

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Finding GameObject and waiting for invisible
« Reply #14 on: August 20, 2016, 08:33:45 PM »
This works because I am using a Wait. The game then renders the GameObject that "ShowStory" activates before it continues to where it's finding that GameObject (PlayButton), but I then rely on the person not clicking the button too fast and that isn't very solid.

« Last Edit: August 20, 2016, 08:42:01 PM by Gatsu »