playMaker

Author Topic: Prefab send event doesn't fire  (Read 3433 times)

christianstrang

  • Playmaker Newbie
  • *
  • Posts: 16
Prefab send event doesn't fire
« on: June 08, 2016, 10:19:24 AM »
I'm having trouble calling a global event from an instantiated prefab.

A bit more information: I have an FSM with 2 states:
- State (Start/Default State)
- Spawn Object A (connected by a global spawn even called "SpawnA")

If I call SpawnA after a button is pressed, everything works fine. But if I put a "Send Event" Action on an instantiated prefab which calls SpawnA after the user clicks on the prefab, the event is not called (but every other action from the prefab is executed).

I triple checked my setup and my conclusion is that you can't simply call a global event from a prefab, only when I use a listener state + a global event does it work.

Is this correct? If so, why? It would be a lot easier to have just a couple detached states in an FSM that can be called via global events instead of having a listener (of course it wouldn't change that much, I just prefer the simpler solution).

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Prefab send event doesn't fire
« Reply #1 on: June 08, 2016, 11:10:59 AM »
Can you post a screenshot of your FSM and Send Event action?

What you describe sounds like it should work.

christianstrang

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Prefab send event doesn't fire
« Reply #2 on: June 08, 2016, 11:31:19 AM »
Not sure if these two screenshots are enough, let me know if you need to see anything else :)

The "SpawnResearchBubble" is working, the "SpawnMiniBubble" which is called from the prefab, isn't.

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: Prefab send event doesn't fire
« Reply #3 on: June 08, 2016, 11:40:57 AM »
Hi,

I guess it would help to know where and how you save the prefab to the 'bubbleContainer' GO variable. If it doesnt save properly, that may be your issue.

Also you seem to have an itween action after you destroy the object, it is my understanding that it will not fire as the object will be gone. Also also :) ,  there is a destroy self action, which may be useful to you.
« Last Edit: June 08, 2016, 11:44:24 AM by Zeldag »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: Prefab send event doesn't fire
« Reply #4 on: June 08, 2016, 12:21:06 PM »
These are good tips from Zeldag.

Check the Debug setting at the bottom of the State panel to see variable values at runtime. This lets you quickly verify that variables have the values you expect.

christianstrang

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Prefab send event doesn't fire
« Reply #5 on: June 08, 2016, 01:55:06 PM »
@Zeldag: Thank you for the "Destroy Self" suggestion, didn't know this exists. Though in this case its actually helpful to have the delay option for the destroy object action (so I can see the punch scale, even though its not timed correctly).

The BubbleContainer is a global Gameobject Variable. I use "Get Owner" => "Store in Game Object" to save the gameobject to this global variable when it is setup. I also did this with another object and it works there (which is why I assumed this is correct here as well).

I'm not sure how to use the debug area :/

How would you usually reference a gameobject from the editor to a prefab? I though my way with the global variable and Get Owner would be fine?

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: Prefab send event doesn't fire
« Reply #6 on: June 08, 2016, 03:10:38 PM »
Sorry, I did not notice that you were using the delay option, doh.

It sounds like it should be working the way you have described it. In my noob experience I had simmilar issues, where I copied and pasted something and then forgot to change the variable (so I would have two FSMs saving different GOs to one global variable) and stuff, not saying you necessarily did this , but just brainstorming.

But in regards to the debug I think what Alex refers to is being able to view variables in inspector during play. This would help know if it really is the GO you expect in the variable.

Basically select the game object that contains the FSM, in the variables tab, on the editor, select the 'bubble container' global variable and tick the 'inspector' box.

Then when you play, click on the object and view the FSM in the GO's inspector, it will show you the name of the actual GO contained by the variable. If this is not the same as the actual object you are trying to send an event to, then something is wrong.

(I've never done this with Global variables, but I think it should Work the same).

On a side note; if the prefab is the only game object using this global event, as a test and, at least a temporary, workaround try to send the event by 'broadcast to all'.

Good luck with it.

Screenshot:
(This is a screenshot from Google imagez , in the image 'network sync' is highlighted, but you need the 'inspector' tick box just above it)

https://www.google.co.uk/search?q=show+in+inspector+global+variable&client=tablet-android-asus-nexus&rlz=1Y3NDUG_enGB514GB514&espv=1&prmd=vin&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjrvbXljZnNAhUHIMAKHdRVAkQQ_AUICCgC&biw=962&bih=553#tbm=isch&q=playmaker variables show in inspector global variable playmaker debug options&imgrc=tvy2rxLzJGY3xM%3A

christianstrang

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Prefab send event doesn't fire
« Reply #7 on: June 09, 2016, 10:25:58 AM »
Thank you Zeldag.
I attached a screenshot and it seems like the reference to the gameobject is working. I wasn't able to check the inspector mark as it seems to only work for non-global variables?

Really odd issue, I know I did something wrong with the setup, but I have no clue what ^^