playMaker

Author Topic: SetState VS SendEvent[SOLVED]  (Read 1200 times)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
SetState VS SendEvent[SOLVED]
« on: August 03, 2020, 10:48:20 PM »
Hey! Looks like I'm missing some basic concept. Let's say I have a prefab with FSM in my project. I can target this prefab as an event target from unity's UI button (placed in the scene) and run SetState action. This will perfectly run the actions in the state. BUT I can't use the same event field on UI button to run SendEvent action to the same FSM. Why?

If the same prefab with fsm is placed in the scene - both ways work perfectly. But if prefab is not in the scene - only SetState works.

I'm trying to make some actions on GameObject which sent events, and I thought I can catch it with GetEventInfo but I can't do it without actual event... I can't get the info who sent me SetState command, right?
« Last Edit: August 10, 2020, 03:37:50 AM by jeanfabre »
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: SetState VS SendEvent
« Reply #1 on: August 04, 2020, 05:46:13 AM »
Perhaps it's a problem caused by the fact that a prefab's content cannot target a non-prefab elsewhere in the hierarchy. Typically, blue stuff only sees blue stuff.

Also, are you using PlaymakerFSM.SendEvent? Do you have only one FSM on the prefab game object? It's likely Unity would send info only to the first iteration of a given component on a GO.

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: SetState VS SendEvent
« Reply #2 on: August 04, 2020, 06:21:39 PM »
My main concern is why SetState action actually works and SendEvent - don't. Yes, that's only one fsm on prefab. I use regular event from UI button and selfmade proxy event. Both didn't work, while SetState action targeting this prefab simply activate it and work smooth  :o

PS. I made a turnaround C# script for this particular task, so it's not a real problem. But the overall concept issue didn't let me sleep well  :-\ 
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: SetState VS SendEvent
« Reply #3 on: August 05, 2020, 11:13:20 AM »
Hi.
Set State is Something used internally, but can be used external.
Send event will check first if its allowed to do so and also register data.

so internal i think the send event is using the Set State after certain conditions. (when a send event action is called)

I think event the Transitions is using the Set State.

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: SetState VS SendEvent
« Reply #4 on: August 09, 2020, 03:05:46 PM »
That sounds fair! Thanks for clarify
indie developer of multiplayer adult fighting
http://nakedfighter3d.com