Playmaker Forum
PlayMaker Updates & Downloads => Official Action Updates => Topic started by: Alex Chouls on May 17, 2014, 12:58:57 PM
-
First a huge thanks to Lea Hayes for doing all the hard work on this action!!
The Conditional Expression action lets you evaluate an expression as true or false and store the result or send events based on the result.
You can use named FSM variables in the expression. If the variable name has spaces use this format: $(variable name with spaces)
Anyway, have a play with it and post feedback. This should be considered a beta release. The final version will be included in the next update.
And again, a huge thanks to Lea Hayes for contributing this action to Playmaker!
Lea makes the excellent Rotorz Tile System: http://u3d.as/content/rotorz-limited/rotorz-tile-system/2UU
He also has a great blog: http://leahayes.wordpress.com/
And Rotorz blog: http://rotorz.com/blog/
EDIT: Updated to v1.1:
- Made text field bigger.
- Added Refresh button.
Some sort of auto-refresh is preferable, but it will need editor support, so for now there is a manual refresh button for when you add/remove/edit variables and then return to the action.
EDIT: Fixed build error.
-
:o oWoow
EDIT: I like seeing programmer centric actions. Being able to evaluate little bits of code like this might not be strictly 'playmaker style', but it would really cut down on action clutter and it's quite awesome!
And I'm also happy I avoid spaces in my variable names now :)
-
Awesome! ;D
1) First thing I would suggest is a bigger space to type the expression =) Like the comment action field has.
2) Also during the editor mode you have to actually click and change the expression field if you want it to re-evaluate any variable changes you've made in the editor.
-
Hi,
Very cool, I would see straight away a lot of thing to expand on this.
expression should allow the return of more than a bool, floats, ints, string, etc. I feel it could be frustrating to get such a convenient action to just return bools, but I am not sure how it's made under the hood, so it may be not really possible to expand on this.
also, I tried to use a string variable but I think the value will always evaluate to true, I think it should evaluate string for "1", "true" "false", empty or with content and return true or false on these cases.
Or, maybe double check what variables are use and warn the user about unsupported variable types within this expression
Bye,
Jean
-
Awesome! ;D
1) First thing I would suggest is a bigger space to type the expression =) Like the comment action field has.
2) Also during the editor mode you have to actually click and change the expression field if you want it to re-evaluate any variable changes you've made in the editor.
Great feedback! I've uploaded v1.1 above...
-
expression should allow the return of more than a bool, floats, ints, string, etc. I feel it could be frustrating to get such a convenient action to just return bools, but I am not sure how it's made under the hood, so it may be not really possible to expand on this.
I'm looking into this - maybe Lea will help out :)
But I think it will be a separate action, e.g.,: Math Expression.
also, I tried to use a string variable but I think the value will always evaluate to true, I think it should evaluate string for "1", "true" "false", empty or with content and return true or false on these cases.
Or, maybe double check what variables are use and warn the user about unsupported variable types within this expression
Good point. This should be possible...
-
Build errors! Woo!
This is for Standalone. It also happened on the previous version.
The line compiles apparently, so I assume its not being picky about formatting. (edit, actually it fails without any actions being used, so its in the dll)
-
Thanks! I'll fix this in the next release...
-
Uploaded a new version that should fix the build error.
-
Works great, I can't seem to break anything else on it. Going to start using it on future iterations of the flight AI and might find more out then. Bundling lots of conditions into a bool value is going to be so useful for AI, especially with a delegate fsm just reading contextual data and flipping bools, then the behavior fsm responding to those flags async.... *hnnnngggghh*..
Only other thing I notice that could be a small nuisance is toggling the expression box to a variable and back will null the field, so you lose anything you might have typed in. Really just a minor inconvenience on the rare occasion that you hit the button accidentally.
-
Great! Please also keep an eye on performance as you use this. I'll build a stress test to compare expressions to regular actions, but I'd also like real world tests...
-
This is fantastic! Many, many thanks to the developer!
One question... What if I wanted to get the "X" value of a vector2 variable (or vector3 variable) to test? Would it be something to simply extract and place into a float or would there be something like a "Vector2.x" or "Vector2[1]" kinda thing?
edit: using "Vector2.x", "Vector2[1]" and "Vector2{1}" all produce errors... So, can I get it to fetch the values within the expression itself or is this something that I'd do with an action external to this function? If the suggestion to me is to extract them separately, I'd love to suggest the ability to work with vectors (both 2 and 3)
-
I also agree with Jean that it would really expand functionality if we had different variable outputs. I would love a similar math action where I could do things like, example:
(myFloat1 + myFloat2)/myInteger = myOutput float
everyframe
Does that make sense?
It could really cut down on the clicks and extra actions
-
That would definitly help a lot !
+1 for math action
-
I think I may have stumbled on a potential bug here... Not sure if this is with the expression system itself or if it's with the prefab management thing but here goes the details.
I've noticed that sometimes the conditional expression doesn't always update the proper expression in the field when working with it as a prefab and adjusting or changing it. The expression shows the right one but it behaves like a previous change/edit/etc... The workaround I found was to simply remove that action and re-add it and put the expression in again which makes me think that there may be a bit of confusion in how the expressions are stashed and handled. It's not something I can easily reproduce but if I do come across it again I'll do what I can to save the information so that I can maybe post a package link.
Still, I can't say that this sours me on this system... It's fantastic! But as with it being beta I can totally understand how there may be some bugs to work out or that kinda thing (and it may not even be with the system itself but rather the prefab management thing that was (is?) an issue.)
-
One thing that I think could bear mentioning here is that this action is quite helpful in making complex actions simpler.
For example... I have it working in the camera control system where I want to make the camera move if the player is outside of a certain range. Previously I'd have to set up a system that uses the float operators, bool tests, that kinda thing and then do a test... And since some of those work best as a sequential action that meant I'd have to make that system cycle through every frame/unit-of-time.
This changes... Now I just get the position of the player and camera every frame and in the expression itself I have "player-pos > (camera-pos + padding)" for each direction. Saves me time and really makes for a much cleaner state.
So, I guess this is me singing praise for Lea's work. Thank you!
-
Hi, the plugin is cool, I suggest that the next update would allow to access global FSM variables
-
Could someone just expand on the functionality how does it get access to variables just by naming them,and are we talking about the variables that are only attached to that specific FSM
Thanks
-
Could this be used to remove trigger boxes based on camera distance,like if cam-Pos = to collider then remove otherwise show
-
I tryed with this action It's Work fine in pc but not Working on Mobile.
i'm i missing something?
-
This is very useful. It would be great if it could work with global variables.
I hope this hasn't been abandoned since it is undocumented and not implemented in the PlayMaker package.
-
I have a question concerning Conditional Expression Action and strings. How should the Expression look for checking wether a string matches or not?
string == "something" ?
Is there any documentation for the Expressions syntax and/or operators?
-
Yes, put the value in quotes, e.g., name == "Bob"
There's some documentation here:
https://hutonggames.fogbugz.com/default.asp?W1226
It could probably use a bit more detail in terms of syntax and operators allowed.
But the result field gives you feedback as you edit the expression which should help...
EDIT: BTW this action is now included with Playmaker, so you should use that version.
-
@Alex Chouls
Thanks a lot! And looks like the online documentation got a little extended ;-)
Regards
-
Yeah, I added the string example :)
-
Can you call for global variables? If so, how the expression would be?
Thanks!
-
Hi,
Good questions! I have pinged Alex on this. We'll know soon.
Bye,
Jean
-
It would be grand if this action could be updated with an "Error Event" similar to the "xml select single node" action for when the content of the string variable used to store the condition is invalid.
I'm using the conditional expression action to test conditions read out of xml files and if there's a mistake somewhere in one of them (which happens easily) the fsm simply stops working instead of allowing me to output an error message.
This would help greatly to weed out those errors without bogging down the whole system.
-
Okay, I found another problem with this action that kind of makes it not viable anymore for what I actually wanted to use it for.
When using a string variable to change the actual expression (not the values of the variables used) in runtime it just doesn't update properly and continues to use the initial value of the string variable set in the editor.
Edit: it doesn't work properly when you change the value of the string in the editor either, even with the "refresh" button... I can't believe I hadn't noticed that earlier.
Any chance of someone picking work on this action up again? This is actually pretty major for me since I started redesigning "availability checks" of events and other things around this action... probably should've tested it more thoroughly... for some reason I didn't notice this for quite some while.
edit2: Well, turns out when used in a template it works properly the first time around, but afterwards it uses the string value from the first run... and I'd only done a test run with one "item", saw it worked and then started implementing it everywhere.
-
Hi,
and if you reenter the state where you have the expression, does it work then?
I would raise a bug report on this too anyway. It would be good to change expression at runtime I agree.
Bye,
Jean
-
Hi,
thanks for the reply Jean. I just set up a small test FSM (see attachement, ignore the error log, those are unrelated) to show the behavior.
Using a bool variable called "Bool":
a) Bool variable value is true, Expression string is initially empty.
-> it will check correctly once after the expression has been changed from empty to "Bool==false" and return "false". It will then just continue to return "false" in a loop even though the expression has changed to "Bool==true" and it should return "true"
b) Bool variable value is true, initial Expression string is "Bool==true"
-> it will continually return "true" in a loop, even though the start state set the Expression string to "Bool==false" and false should be returned.
Similarly if you set the Expression string in the editor initially to "Bool==true", open the state and click "Refresh" on the action it will return "true". If you then change the value of the string to "Bool==false", go back to the state and click "Refresh" it will show the changed expression but still return "true".
Edit: Bug report submitted (I hope this is something that can be resolved quickly, it's causing me a major headache right now)
cheers
-
Hi,
I have raised the case internally, hopefully this is something feasible.
Bye,
Jean
-
Please try the attached version of the action.
It should recompile the expression if it changes.
-
Heya, thanks for taking a look at this.
I've tried it and got the following compiler error:
Assets/PlayMaker Utils/Wizards/LinkerWizard/Editor/LinkerEditorChecks.cs(17,66): error CS0433: The imported type `PlayMaker.ConditionalExpression.ConditionalExpression' is defined multiple times
Can only be resolved by deleting the ConditionalExpressionAction.cs from this package after which the original one still remains but can't actually be located anywhere in the project. :/
When trying to locate it:
Couldn't find Action Script: PlayMaker.ConditionalExpression.ConditionalExpression
UnityEngine.Debug:LogError(Object)
HutongGames.PlayMakerEditor.ActionScripts:PingAssetByType(Object) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Editor/Classes/ActionScripts.cs:123)
UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)
I also tried it in another project I set up only a couple of days ago with the same result.
Edit: the "couldn't find action script" error occurs before trying to replace the action as well, btw. so it probably wasn't caused by it but rather is connected to the reason why the replacing doesn't work. (I hope I'm not just being dense here... I'm not a programmer myself, so I'm just fishing :D )
-
Hi,
Yes, this package is not the right one, So it won't install properly.
I did test on the latest beta and I can confirm that both global variables and expression update are now working, so watch for the next PlayMaker update on the Asset Store, it will be available then.
Bye,
Jean
-
Hi,
Can you download it again from the post above, it's now featuring the proper dll.
Bye,
Jean
-
Yes, it works now. Thank you guys so much. :)
-
Hi,
Yes, this package is not the right one, So it won't install properly.
I did test on the latest beta and I can confirm that both global variables and expression update are now working, so watch for the next PlayMaker update on the Asset Store, it will be available then.
Bye,
Jean
How do you call for the global variable? Could you write down an example for the expression, please? :)
-
Yeah, that interests me too, didn't download the latest version to check if any instructions are included though.
-
Hi,
you reference the global variable just as you do for the local variables, it's been fixed, you need to the latest version of PlayMaker.
Bye,
Jean
-
Awesome 8)
-
Rise from your grave!
Hi!
How does one test for non-single element FsmVars like vectors 2/3, quaternions, enums or stuff like that?
-
Hi,
Yeah, it would be great to be able to access more complex variables indeed. Can you report this using our bug report so that we can keep track of this request, I think it's a good improvement to make.
Bye,
Jean