playMaker

Author Topic: Activate Game Object Weirdness  (Read 3764 times)

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Activate Game Object Weirdness
« on: March 07, 2016, 11:04:39 AM »
I have a canvas with Unity buttons on it (Canvas1).  There are three buttons... PLAY, PAUSE, STOP.  (Only PLAY is showing... PAUSE/STOP are hidden).

I have another canvas (Canvas2) with Unity buttons on it ... SHOW CONTROLS and HIDE CONTROLS.  When these buttons are clicked, the Canvas1 game object is activated/deactivated and the buttons on the Canvas1 appear/disappear.

For example... if the PLAY button is visible but the PAUSE and STOP buttons are invisible and the user clicks the HIDE CONTROLS button... Canvas1 disappears.  When the user clicks the SHOW CONTROLS button... Canvas1 reappears showing only the PLAY button (not the PAUSE and STOP buttons).  This is working perfectly.

But I also have it setup in the FSM (using Get Key Down), that the user can press the H key and do the same thing as when pressing the HIDE CONTROLS/SHOW CONTROLS buttons.  This is working fine too.

Problem is-

When the user uses the H key method to hide Canvas1... it hides the canvas just fine but when the user uses the H key again to unhide the canvas it unhides the canvas but (unlike the button method) briefly shows the PAUSE and STOP buttons before hiding them leaving only the PLAY button visible.

I would like to not see buttons that were hidden when hiding/unhiding the canvas.

Basically the button method works flawlessly and the key press method gives different results... even though the buttons and key press are sending the SAME event!

Any idea how to make the key press method work like the button method?

Thanks!
« Last Edit: March 07, 2016, 03:19:50 PM by mTruly »

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Re: Activate Game Object Weirdness
« Reply #1 on: March 19, 2016, 12:52:07 PM »
Bumping this up again.

Basically, the button method hides/shows the canvas and all looks good.

But when the Get Key Down method is used to do the same thing (specifically, re-activating the canvas), the hidden buttons on the canvas (which are supposed to NOT be active/visible) breifly flash visible before being properly de-activated and hidden again.

Basically, two different visual results when doing the same thing... de-activating/activating the canvas.

Thanks for any ideas!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Activate Game Object Weirdness
« Reply #2 on: March 19, 2016, 06:15:58 PM »
Hi,
Maybe it is better to use 1 canvas.
What i do is have 1 canvas and several 'panels' for each menu part
Something else that might be helpful is the action "next frame event'

I think the button method might automatically do a next frame and the key not.

If this does not help can you show a video or some pictures with your fsm's/actions

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Re: Activate Game Object Weirdness
« Reply #3 on: March 21, 2016, 10:54:43 AM »
Here's a small screencapture showing the problem.

When the canvas is activated via the button... the visual result is perfect.

When the canvas is activated via the keypress... buttons which are hidden in the state are breifly shown before being hidden again.

(** In the video, the first time the key is pressed the problem is not shown because of the screen capture software but it does happen every time the button is pressed).

Thanks!
« Last Edit: March 21, 2016, 10:57:43 AM by mTruly »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Activate Game Object Weirdness
« Reply #4 on: March 21, 2016, 12:41:30 PM »
Hi,
I need to see the states and actions for both, using buttons and using keypress
so i can see what the problem might be.

you can make a bigger video and upload it to Youtube and share the link :)

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Re: Activate Game Object Weirdness
« Reply #5 on: March 21, 2016, 09:12:58 PM »
Here's a couple of screengrabs showing the actions in question.  The UI button press and the keyboard button press both send the same events.  But the UI button press produces one visual result and the keyboard button press produces another.

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Activate Game Object Weirdness
« Reply #6 on: March 22, 2016, 07:08:45 AM »
Hi,
The actions seem fine but i can't see what the other action are and since the actions are renamed i can not know what the actions are.

Did you try to add a state with a "next frame event" action between those states?

Personally i do not like to change the original action names, i commonly use the description to explain what i do in a certain state so it is easier for me to troubleshoot if there are some bugs. especially when actions reach 1000+
it is better for me to have the original action names.

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Re: Activate Game Object Weirdness
« Reply #7 on: March 22, 2016, 10:00:03 AM »
Thanks for taking a look.

All those hide and show actions are simply 'Activate Game Object' actions...  they just make different UI buttons visible or invisible.  They have nothing to do with the problem.  The expanded actions just show that the two states either hide (deactivate) or show (activate) the canvas object.

Since both the UI button presses and the keyboard button presses send the same events (basically change states), and the UI button presses produce clean results and the keyboard presses do not... I think only the Playmaker developers might have insight as to why things are displayed differently.

It seems...

The UI button press sends event to change states.  When this happens, the canvas is activated BUT it's children (the UI buttons on the canvas) are activated/deactivated first, then the canvas is displayed.

The keyboard button press sends the SAME event to change states.  When this happens, the canvas is activated first along with all it's children (the UI buttons) and all the UI buttons are activated (displayed) briefly, then the UI buttons are properly shown/hidden according to their individual 'Activate Game Object' actions.

Essentially, two different visual results from sending the SAME event.

Yes, I tried putting a state with 'Next Frame Event' between the states but it did nothing.  I also tried moving the 'Show Playback Controls CANVAS' action to the bottom of the stack to see if that made a difference but it did not.

The only thing I can think of that might work is if there was a way to have the 'Get Key Down' action NOT send the event to change states but rather have it simulate the UI button press instead... not sure how to set this up.

Thanks again.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Activate Game Object Weirdness
« Reply #8 on: March 22, 2016, 03:16:44 PM »
Hi,
You Can try to use "Action Sequence " (when in a state, right click on the right side and select it)

And set the ones that disable on top.

If that stil don't work can you send the scene so i can figure out what the problem is?

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Re: Activate Game Object Weirdness
« Reply #9 on: March 22, 2016, 04:13:42 PM »
Sorry, I can't share the file at this point.  Later when I get some more time, I may try to make a simpler test case that I can share.

Thanks again for looking into this.

mTruly

  • Junior Playmaker
  • **
  • Posts: 98
Re: Activate Game Object Weirdness
« Reply #10 on: March 30, 2016, 09:13:53 AM »
OK, an update on this.  I'm not sure what I did but this particular problem seems to have gone away.

Now when using the key press to hide/show the canvas, it gives me the same clean visual results as when using the UI button to hide/show the canvas.  No more brief flashing of hidden UI buttons on the canvas.

Weird.