Playmaker Forum
PlayMaker Feedback => Action Requests => Topic started by: MS80 on June 30, 2014, 07:41:42 AM
-
How to send a message to a script with more than one parameter of different type needed?
F.e. PostScore(string name, int score)
The action "send message" allows only one parameter, is it possible to create a action with more than one parameter (f.e with integrated temporary array)? Maybe there is another solution?!
Hope you can help me...
Thanks!
-
Hi,
Currently, it's not really possible. You'll have to make a custom action to call that method with several parameters.
[EDIT] It is indeed possible using the "call method" action.
Bye,
Jean
-
SendMessage is a Unity function and only accepts one parameter.
But you should be able to use Call Method to call a method with multiple parameters...
-
D'oh :)
Thanks Alex for correcting me, I forgot about that action... :)
Bye,
Jean
-
Thanks! I already found the "Call Method" action, which is great! Also found a testpackage how to use it, unfortunatly I dont get it to work with the script I need!
I get the errormessage: Method Name is invalid: PostScore
Attached is a script which works just fine, but I want to control this script via playmaker (parts of it without the gui stuff)! Setting the string and int is no problem, function "GetScore" works, too! But function "PostScore" needs 2 parameters (string, int). If I use "PostScore" with only one parameter I can use it with "send message" action...
Hope you can help me.
-
Hi,
there is a know bug in where if the method as different signatures it gets confused.
Bye,
Jean
-
There's an updated Call Method action here:
http://hutonggames.com/playmakerforum/index.php?topic=7526.0
Please give that a go. It should fix the bug with method overrides...
-
Sadly no! :'( I have already tried the updated Call Methode action...
=> "Invalid Method Name or Parameters: PostScore"
I also tried "get component" workaround, without success!
Any ideas??
-
This is with the update? And parameters set to match the method signature? Can you post a screenshot of the Call Method action setup?
-
Sure! Here is a screenshot....
I used the one you provided (with the link above).
Parameters should match the method (Playername=string, Score=int)
Errormessage is the same if I use get component and use component variable...
-
Does PostScore have a float return type?
-
To be onest I dont know if it has a return type, I assume not (script is attached in upper post)! Thought if variable is set to none it is ignored....
I recognized a second error message in the console:
"Failed to call function PostScore of class Highscore
Calling function PostScore with no parameters but the function requires 2.
UnityEngine.MonoBehaviour:StartCoroutine(String)
Highscore:Start() (at Assets/Highscore/Script/Highscore.cs:30)"
-
Hi,
I see, you can't typically use methods that are asynchrone, which is exactly what you are trying to call.
so, create a new function "void CallPostScore(PostScore(string name, int score)" that simply calls in turn PostScore, and that is going to work.
Bye,
Jean
-
Thx Jean!
Sorry beeing a bonehead... tried what you descriped but no matter how I do it, getting lots of errors :-\
Could you please go a bit more into detail how to add the function and to call in turn PostScore? maybe showing off a small code snippet ?!
-
Hi,
yes of course:
here is the new method you need to add to the script itself for "Call Method" action to work:
public void CallPostScore(string name, int score)
{
Debug.Log("CallPostScore");
StartCoroutine(PostScore(name,score));
}
so in the "Call Method", the method will be "CallPostScore" and you create 2 variable, one string and one int and you are good to go!
Bye,
Jean
-
Many thanks, Jean!
I was very very close to it, no idea what was going wrong!? :-X
Now it performs like expected! "CallMethod" action is a mighty one, it even showed me a error because the function has no return, after setting to "none" it runs out of the box!
I salute the way how playmaker cooperates with script components, it multiplies it's power!