playMaker

Author Topic: Send Message with more than one parameter?  (Read 18615 times)

nuverian

  • Playmaker Newbie
  • *
  • Posts: 5
Send Message with more than one parameter?
« on: April 22, 2012, 02:27:29 AM »
Hi,

Well, the titles says it all I think. :-). Do I need to create such action to allow more than 1 parameter to pass to the function or is there another way. In any case I tried to alter the SendMessage.cs but failed. :-/

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send Message with more than one parameter?
« Reply #1 on: April 22, 2012, 03:02:08 AM »
Hi,

SendMessage only accepts one parameter. But this is not really Playmaker related. In short, to send multiple parameters, either than a class you created and simply access its param and function as usual, else you can pass a hashtable, or an array, things like that.

In playmaker, You can send Events and add Data to that event. Check out the following actions:
https://hutonggames.fogbugz.com/default.asp?W531
https://hutonggames.fogbugz.com/default.asp?W530


 I do need to pass more than one parameter within playmaker, It's fine if you need to pass a string, a float, and an int, but the data structure of events is unfortunatly very limited, you can not pass more than one string, more than one float, etc etc, and you can't a hashtable for convenient retrieval. So I tend to NOT pass data when it becomes complex, instead I rely on other technics such as:

-- send a event to a Fsm, that fsm will then query the caller or what it needs when it receives that events, this is much easier, but introduce some dependancies, aka the receiver has to know where to get the informations. This is solved by creating what I call "META" Fsm, that acts as data repository, so if I have a player, all my enemies have a reference of "META PLAYER" fsm, and when the player wants to comnunicate with an enemy, it send an event, with no data, and the enemy simply pull from "META PLAYER" what it needs to react and act upon this event.

 Hope that make sense :)

 Bye,

 Jean

nuverian

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Send Message with more than one parameter?
« Reply #2 on: April 22, 2012, 03:16:09 AM »
Thanks for the reply, but..um. Im lost here. I don't want to send an event, but a message. or in essence call a function that needs two parameters passed and which lies in a script which is attached on the same gameobject as the FSM is.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send Message with more than one parameter?
« Reply #3 on: April 22, 2012, 06:55:08 AM »
Hi,

 Even in Unity, without playmaker, you won't be able to use sendMessage() to one of your function that accepts two paramater, the sendMessage() doesn't allow you to pass more than one variable.

http://unity3d.com/support/documentation/ScriptReference/GameObject.SendMessage.html

The only way ( if you are not able to modify this method with two variable), is to create a custom action, that actually will reference that script, and then call it explicitly.

 I have attached a fully working example ( You need to import playmaker of course).

In this scene, there is a "MyScript" which is a normal script with a "MyMethod" that have two variables in its signature and returns a string.

to call this from playmaker, I created a custom Action called "MyScriptBridge" that essentially will require that you point to a gameObject with a "MyScript" component attached to it, and call the "MyMethod" with the float and vector3 of your choice, it will also give you back the result in a string.

 this is essentially how you would solve your case without doing much work. Obviously, you will need to change the name of the class to match yours, also change the name of the method, and the argument types, and you might not want to expect a return from it.

If that still doesn't make sense, don't hesitate to ask for more explanations.

 Bye,

 Jean

 

nuverian

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Send Message with more than one parameter?
« Reply #4 on: April 22, 2012, 12:52:30 PM »
Thanks for reply and the action..That does makes sense, yes. I will give this a try and let you know

Best

weilies

  • Junior Playmaker
  • **
  • Posts: 74
Re: Send Message with more than one parameter?
« Reply #5 on: February 28, 2015, 09:19:18 AM »
sorry i know this is an old post.
"Send Event" no longer support parameter? (as attached image)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Send Message with more than one parameter?
« Reply #6 on: February 28, 2015, 09:50:14 AM »
Send Event and Send Message are different actions.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

weilies

  • Junior Playmaker
  • **
  • Posts: 74
Re: Send Message with more than one parameter?
« Reply #7 on: March 01, 2015, 04:17:17 AM »
sorry plz ignore my previous question then.
i m planning to "Send Event" with parameter, is it possible?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send Message with more than one parameter?
« Reply #8 on: March 03, 2015, 12:31:46 AM »
Hi,

 Check this post:

http://hutonggames.com/playmakerforum/index.php?topic=4296.msg21612#msg21612

 it's an extended version of event data where you can set multiple datas

Bye,

 Jean