Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

PlayMaker - Visual Scripting for Unity

Discussion in 'Assets and Asset Store' started by Alex-Chouls, Dec 31, 2010.

  1. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    How to use keyboard inputs? I can only see mouse inputs in the transition options.
    I see INPUT in Actions but I tried to add one to an object but nothing happens.
     
  2. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    How do I keep the camera pointing to an object? I added LOOK AT action but it only look at the object once at startup... how do I make this continuous?
     
  3. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @frido - it's actually hard to do without the proper transform actions. I'll post RC2 tonight, it has a sweet GetAxisVector action that does all the math for you:

    $GetAxisVector.png

    Will also have TransformPoint, InverseTransformPoint, TransformDirection, and InverseTransformDirection actions so you can do the math yourself...

    @megmaltese - when you say nothing happens, have you defined an event for the key to send? The events in all caps are system events generated either by Unity or Playmaker. Generally you'd also add your own events in the event manager and trigger those with actions. Also the game view needs to be focused to register keyboard input...

    I want to test a bit with the new Unity update, and make some more sample scenes/actions this weekend. Then I plan to submit to the asset store early next week.
     
  4. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @megmaltese - LookAt should update every frame by default... just tested it here and it works... is the state it's on active?
     
  5. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Lookat is only aligning the object at startup, tried right now on another object (before I tried on the main camera) and still it only aligns at start.
    Then I click the cube, it rolls away and the capsule is not rotating.
     
  6. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Hmmm... can you send me the scene? Or email me repro steps... thanks!
     
  7. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    OK I defined a new event... how can I edit it?
    I mean... I added a transition that if I press P an object change state... nothing happens.
     
  8. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Here it is :)

    By the way, there's also the event for keypress :D
     

    Attached Files:

    Last edited: Feb 12, 2011
  9. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
  10. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Ok, I took a look at the scene:

    LookAt: You have to target an object in the scene, not the prefab. If you set the target to cubbo (not CUBBO) it works as expected. It's funny that cube has some character for just a little torque added!

    GetKeyDown: State 1 is never active, so the action is never executed. Perhaps you're used to virtools style building blocks where all top level blocks are active...? Playmaker is a finite state machine editor, so only one state is active at a time. To get more parallel behavior, you can use separate state machines that talk to each other. Ultimately Playmaker will have a hierarchical FSM which will let you nest more states, but that won't be until the next release...

    EDIT: Just in case it isn't obvious (since the getting started video only used one transition), you can add as many transitions as you need to a state. So to fix your example, move GetKeyDown to the off state and add the A_KEY transition to it.

    BTW, at runtime, the active state and any running actions are highlighted green in the Playmaker editor.
     
    Last edited: Feb 12, 2011
  11. Altitude

    Altitude

    Joined:
    Oct 17, 2010
    Posts:
    11
    I was picking my jaw off the floor after watching those videos. As a visually orientated individual myself who runs away from coding like mad - what a fantastic solution this appears to be.

    If Unity 3D adapted Playmaker to it's own core functionality then it really would be like "RPG Maker" for adults.

    The game development world is coming full circle where it began as a single game producer in their basement tinkering away at a title that could be released on the market as a 1 man team - to hundreds of people, and now we are back to having the abilities in the Indy market to hit mainstream without that kind of overhead.
     
  12. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    I agree. As the tools become more accessible it's going to be really interesting to see what new visions are out there. In many ways game development has become inbred with the same recycled games made by gamers for gamers, but tools that say "hey here's a powerful 3d engine, make interactive content, you don't need to program" throw the doors wide open.

    I hope Playmaker can play a part in that. Certainly the open beta has made it a better tool thanks to all the feedback and bug reports... so please let me know what could work better, what ideas aren't clear etc.
     
  13. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    RC2 is now available: download

    Want to test it some more with the new Unity 3.2 update, and make a few more samples/actions before submitting to the store.

    NOTE: Actions saved with older betas might not update correctly if the action scripts have changed since they were saved, but this should be less of a problem going forward...

    Release notes: here

    Highlights: A couple of big bug fixes, compound arrays for switches, mixers, random weights etc., MovieTexture support, GetAxisVector for easy camera relative motion...

    Getting started videos: here

    Playmaker Beta used in winning entry at Global Game Jam Sydney: http://www.globalgamejam.org/2011/press-3-breed

    A quick physics test: here.

    A quick test with the new MousePick and GUILayout actions: here

    An older sample published for the web: NoExit.
     
  14. ROCFriesePoort

    ROCFriesePoort

    Joined:
    Mar 27, 2009
    Posts:
    107
    Great to hear that! I'll try RC2 this weekend and I'll let you know.
     
  15. ROCFriesePoort

    ROCFriesePoort

    Joined:
    Mar 27, 2009
    Posts:
    107
    I've tried the new GetAxisVector and it worked! Now I'm trying to get the object to face the direction it moves. I think it needs to be done with a LookAt action but it hasn't got a Vector3 target. Is there an other way around this?

    Thanks!
     
  16. elvis75k

    elvis75k

    Joined:
    Feb 5, 2011
    Posts:
    24
    Movie texture works fantastic! Unfortunately there's no www option anywhere, The only problem is the audio included in the movie: it doesn't have controls and it always work as a 3d sound.. The good news: it play and pause with the movie!

    Now: is it safe to customize your predefined action to get the "missing" stuff?
    A sample with the sendmessage is missing.. you could have used my issue to show how it work.
    You will definitely add samples with script controls, will you?

    Thanks anyways for the add.
     
  17. elvis75k

    elvis75k

    Joined:
    Feb 5, 2011
    Posts:
    24
    bug report: in the behaviour selection (enable behaviour) there is now the name of the object and of course it will result in a missing behaviour in the console untill you change the text with the right one. If you can fix this and add a play, pause, stop to audio actions..
     
  18. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    UPDATE: Please re-download RC2 if you downloaded it already - there was a bug with the GUI for string variables in the action editor...

    @Frido - Had a feeling you'd want that next :) LookAt is an older action I made before I had Vector3 variables. Let me take a look at it, and update it...

    @elvis75k - I'll add www and audio actions.

    About customization - I'd suggest you copy and rename the action (and namespace) so it doesn't get stomped on by a playmaker update... but other than that, knock yourself out! Actions are fairly similar to MonoBehaviors and you have lots of examples to look at. However, my goal is to cover the bases with the built-in actions, so let me know when you find holes. Also for support, I'd like to focus more on the built-in actions for now, rather than custom actions... after shipping I can spend more time to help with custom actions.

    Regarding the error in EnableBehaviour - the console warning is there in case you have a typo in that field, otherwise it might be hard to track down. I could switch it to only show an error if the string isn't empty (since that case is handled by the edit time error checker).
     
  19. elvis75k

    elvis75k

    Joined:
    Feb 5, 2011
    Posts:
    24
    Have you got the bug? Open the MovieTexture sample file, open the fsm and add the enable behaviour action where you want. Go in the behaviour rollout to chose the script to enable and you'll get the name "Cube (PlayMakerFSM)". Select this behavior and you'll see it add with name Cube and (PlayMakerFSM) with parentheses that result later in:
    You have to manually delete Cube ().. Ok? That wasn't an issue in RC1
    -
    The bug with the GUI for string variables in the action editor is only fixed if i load the PlaymakerRC2 project from scratch. If i add Playmaker.unitypackage to a new project it push the GUI (node window) away..
     
    Last edited: Feb 13, 2011
  20. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Ahhh I see... It looks like the behaviour of Component.ToString() changed in the Unity 3.2 update... I'll fix it - thanks!
     
  21. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    RC3 is now available: download

    Release notes: here

    Some nice smooth LookAt actions, Audio actions, and some Logic actions...

    Working on some smooth movement actions and more samples.
     
  22. teamwhitesnow

    teamwhitesnow

    Joined:
    Nov 12, 2010
    Posts:
    85
    hey in your "no exit" sample .i was curious on two things 1. how did you make the cursor change to a hand when it was in range of the button 2. did you create the room or walls in something besides unity in other words how did you go about making the level. besides that fantastic work!
     
  23. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    I use MouseCursor and MousePickEvent actions to change the cursor. Check out the ButtonDoor sample for an isolated example. The Cursor game object has an FSM that just controls cursor state, and the Button FSM sends events to the cursor FSM using SendEventToFsm.

    I made the NoExit level and parts in 3dsMax and lightmapped it in unity...
     
  24. teamwhitesnow

    teamwhitesnow

    Joined:
    Nov 12, 2010
    Posts:
    85
    oh thanks alexchouls im starting to get it :) .. so when you made the doors and button were they two different models and you attached them to the level itself? sorry im just trying to understand how i should go about making interactive objects to my levels using the fsm
     
  25. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Yes - they're different models so I could place them independently - e.g., Door04 has the button above it...

    In general it's better to have 3 simple FSMs that talk to each other, instead of one giant FSM that's hard to maintain.

    Think of the states each component part of the game needs - I often use the graph view to just add states and sketch out the flow before adding any actions, just to see how it might work... visualizing the problem can really help you design the solution.
     
  26. Ayzhong

    Ayzhong

    Joined:
    Jul 21, 2010
    Posts:
    18
    I am using playmaker rc3 right now and it's completely awesome. This has got to be one of the best things to ever happen to Unity and game development. :D Anyways, I'm having a little trouble with sending events in transitions. For example, I have a state that has two actions, 1 to get the horizontal axes and the other to get vertical axes. But how do I send events for each action? I'm a little confused, and slightly impatient because this is so awesome!
     
  27. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Not sure what you're trying to do, but I'll quickly cover some core concepts in case that's the problem:

    1. You're breaking behaviors down into discrete states, where only one state can be active at a time. If your axis are controlling totally separate things with their own states, they might need to be their own state machines... e.g., HorizontalControllerFSM, VerticalControllerFSM - it all depends on what you're trying to do. There's an overview of state machines here.

    2. Each frame every Action in the list that has not finished is updated in turn from top to bottom. Definitely read this page if you haven't already: https://hutonggames.fogbugz.com/default.asp?W174

    If that's not the disconnect, here's the general workflow:

    Make a float variable for each axis in the Variables Manager, e.g., horizontalAxis, verticalAxis.

    Now you can use these variables in other actions. E.g. Translate. Just add these actions to the list and hook up the variables.

    If you want to transition to a new state based on the value of a float variable you can use FloatCompare and send an event that you make in the Event Manager.

    If you're trying to move something with the axis input I recommend using GetAxisVector instead of the individual axis. Just make a vector3 variable in the variables manager...

    Remember you can do quite a lot of work in a single state. You only need to transition to new state when you need different behavior. Also remember you can transition to a state to do something (e.g., add some force, fire a bullet, whatever) and return to the original state, all in the same frame...

    I'm working on some more screencasts that should help.

    Let me know if I totally misunderstood the problem!
     
  28. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    Awesome tool you've created :)

    I've been attempting to create a timer that starts when the scene is loaded and will count up in seconds, but didn't get very far now i'm a little confused :p

    I wasn't sure what had been added for timers so rather than persisting and confusing myself further i thought i'd ask :D

    Any words of wisdom?

    Also i'm horrible at coding hence my confusion.
     
    Last edited: Feb 14, 2011
  29. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Thanks!

    You can use PerSecond and FloatAdd to add 1 to your timer variable every second.

    It's a little roundabout, should probably add a PerSecond option to FloatAdd.

    And make some Timer actions... E.g., GetTimeSinceLevelLoaded.

    I also want to make common formatting actions:
    - Stopwatch: takes a float and formats a string as hh:mm:ss
    - Typewriter: takes a string and outputs it one letter at a time with tweakable delay and letter sound effect.

    So you can just drop these into your GUI states... too many actions to make and too little time!
     
  30. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    Hey thanks for the information so far, i'm still unsure of how to put it all together as i don't really understand the logic behind a timer in the first place, when you say it's like a little roundabout i'm unsure of what you mean.
     
  31. Ayzhong

    Ayzhong

    Joined:
    Jul 21, 2010
    Posts:
    18
    You didn't misunderstand, you were right on the mark, though I was bad at explaining. What I didn't do was hook up the variables from the GetAxes to other actions that actually do things.
     
  32. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @Voumerus - Right now you have to do this:

    $timer.png

    You need 2 variables and 2 actions.

    Note, I have Debug checked which lets you see the values of variables in the action editor. If you're ever unsure of what's going on with your variables, just check debug and watch them...

    In the next update, I added a PerSecond option to FloatAdd that lets you do this:

    $timer2.png

    Basically: Add 1 to the timer variable every second.

    Or use the new GetTimeInfo action:

    $GetTimeInfo.png

    Which lets you get lots of different time info, including time spent in the current state.

    EDIT: BTW, if the reason you're trying to make a timer is to transition to another state after x time, you can also just use SendEvent with a delay.
     
    Last edited: Feb 14, 2011
  33. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @Ayzhong - Cool! Let me know how you get along...
     
  34. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    I love the tool, but I do have one question. Can we not add custom built-in events? I know you can add your own, but these are just for individual state machines (as far as I can tell).

    I'm trying to add events for things such as "OnPlayerConnected" for example... Whilst I could do this from custom events, it's a bit of a pain. Could you not implement some sort of framework to allow us to add our own events (such as with actions)? Or am I missing the point of state machines?

    Thanks,
    Rich
     
  35. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    You can centralize event sending using SendEventToFsm. Have one fsm detect the conditions and send events to other fsms. But you still have to send them individually to each fsm. I could add an action to broadcast an event to all fsms.... BroadcastFsmEvent...

    [EDIT: You still have to add the events to each fsm which is a bit of a pain... maybe there should be the concept of global user defined events, accessible from any fsm...]

    The built-in events are convenient though, and to be honest, I added the monobehaviour events that I use most often - I can add more. The networking events seem like good ones to add.
     
    Last edited: Feb 14, 2011
  36. ROCFriesePoort

    ROCFriesePoort

    Joined:
    Mar 27, 2009
    Posts:
    107
    This tool is amazing! RC3 helps us to do things really easy! We have a simple a.i. waypoint system up and running in a couple of minuts. The one thing that we are missing is a RayCast Action that give a boolean result and can be cast from an origin (GameObject or Vector3) to a specified direction/length. Soon I'll post a small prototype.
     
  37. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Great to hear! I'll add a RayCast Action.

    Can't wait to see the prototype...
     
  38. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    The broadcasting of events sounds like a good idea. I would love to have the option implemented! I suppose it could be implemented by myself, though, right?
     
  39. mayaboygirl

    mayaboygirl

    Joined:
    Mar 6, 2009
    Posts:
    1
    非常棒,真是太漂亮了!! i like it very very much : )
     
  40. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
  41. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @RickyBozzy - I'll add a BroadcastEvent action to the next release (later today).
     
  42. elvis75k

    elvis75k

    Joined:
    Feb 5, 2011
    Posts:
    24
    don't forget www actions!
     
  43. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Been looking into www actions, and they might have to wait until I add support for Unity.Object fsm variables (e.g., texture). That is the next feature on my list - it would expose fsm variables for any type derived from Unity.Object...

    Unless you can think of an implementation that doesn't require storing the texture... and doesn't involve duplicating a lot of actions to have WWW equivalents.

    I'll think about it some more too...
     
  44. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    Thank you! I'm looking forward to this feature.

    What kind of time-frame are we looking at until full release, by the way?
     
  45. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    I want to submit to the store tomorrow!

    Honestly I'll keep adding features forever... so I'd rather do it as updates to a 1.0 release than as a beta that never ends!
     
  46. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    RC4 is now available: download

    Release notes: here

    Highlights:
    • BroadcastEvent action lets you send events to lots of FSMs at once, making it easier to create manager FSMs.
    • Raycast and GetRaycastInfo actions with optional debug lines in the scene view so you can see what's going on.
    • GetTimeInfo action to get various useful time properties, including how long the current state has been active.
    • Fixed the tooltip bug on action parameters - can now add a lot more tooltips...

    Also you can now select objects in the running game view to see their FSMs - personally I love this feature, it really closes the preview loop when playing the game. Try the MaterialEffects sample to see what I mean... If you don't want the selected FSM to switch, use the Lock option. You can also turn this feature off in preferences...

    @RickyBozzy - let me know how the BroadcastEvent action works for you. I did some basic testing, but it sounds like you might have a more complete test scenario... and thanks for prompting this feature - I think it will be quite useful!
     
  47. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    Initial tests show that it is working perfectly. I am using it to "damage" any game object within a certain radius by calling an "On Damaged" event in them. Those that want to respond (e.g. enemies) do, and those that don't want to (e.g. walls) do not. This is how I envisioned it!

    There is one "bug" I have found (although it may just be me doing something wrong). When you try to get a GameObject with a MeshRenderer attached, to move (.e.g MoveTowards or Translate) the current actions only seem to move the collider and not the visible representation of the mesh. Is this a known problem, or could it be something I am doing wrong?

    Thanks,
    Rich
     
  48. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,362
    It's something on your side. Make sure the GameObject is not tick as "static" (upper left corner of your screen). Static objects should never move, this causes big overheads on the physics system and of course unwanted behaviors.
     
  49. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    Okay thanks... yep all me, no bug :)
     
  50. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Hmmm, I'm not seeing that with MeshRenderer... Does the GetAxisVectorTest sample scene work for you? Is there anything different about the game objects/meshes?

    Glad BroadcastEvent worked out!