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. shader

    shader

    Joined:
    Apr 4, 2009
    Posts:
    253
    @alexchoulds

    Would you offer an educational discount for a school purchasing say 20 licenses ?
    Also, would the final release version be 'installed' into Unity without needing admin rights. I ask this as I don't know what copy protection you willl use and I would have to add PlayMaker after Unity has been installed on the network. I hope this makes sense
    Thank you for creating a very good product.
     
  2. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @Frido - np!

    @shader - We're looking into educational licensing but don't know exactly how it would work right now. I don't think we can handle it through the asset store... so we'd need another channel for distribution and updates...
     
  3. shader

    shader

    Joined:
    Apr 4, 2009
    Posts:
    253
    Thanks
     
  4. Jiong

    Jiong

    Joined:
    Dec 16, 2009
    Posts:
    22
    Currently i had uses this method expose data in my gameplay system。but i think FSM control panel is best method.
    send custom data also use Component store data.
    like this :
    Code (csharp):
    1.     // Send TakeDamage Message To Target.
    2.     [ActionCategory("Genre/ACT")]
    3.     [Tooltip("Cause Damage to Spefic Target. if Damaged collider is part of Target, we send [OnTakeDamage] to Target.")]
    4.     public class CauseDamage : FsmStateAction
    5.     {
    6.         // TakeHitInfo
    7.         [CheckForComponent(typeof(Damager))]
    8.         public FsmOwnerDefault m_Originator;
    9.         public FsmOwnerDefault m_DamageCauser;
    10.         [RequiredField]
    11.         [UIHint(UIHint.Variable)]
    12.         public FsmGameObject m_Damaged;
    13.  
    14.         private GameObject originatorGo;
    15.         private Damager damagerComponent;
    16.  
    17.         public override void Reset ()
    18.         {
    19.             m_Damaged = null;
    20.             m_DamageCauser = null;
    21.         }
    22.  
    23.  
    24.         public override void OnEnter ()
    25.         {
    26.             GameObject originatorGo = m_Originator.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : m_Originator.GameObject.Value;
    27.             damagerComponent = originatorGo.GetComponent<Damager> ();
    28.             GameObject damageCauserGo = m_DamageCauser.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : m_DamageCauser.GameObject.Value;
    29.  
    30.  
    31.             CauseDamageTo (m_Damaged.Value, damageCauserGo);
    32.            
    33.             Finish ();
    34.         }
    35.  
    36.         void CauseDamageTo (GameObject otherObject, GameObject damageCauserGo)
    37.         {
    38.             TakeHitInfo hitInfo = damagerComponent.HitInfo;
    39.             // Send TakeDamage message to other object.
    40.             hitInfo.DamageCauser = damageCauserGo;
    41.  
    42.             otherObject.SendMessage ("OnTakeDamage", hitInfo, SendMessageOptions.DontRequireReceiver);
    43.         }
    44.     }
    then handle event at target like this:
    Code (csharp):
    1.     // Get Damage Info from DamgeRecevier Component.
    2.     [ActionCategory("Genre/ACT")]
    3.     [Tooltip("Activated when  a certain amount of damage is taken. Allow the designer to define how much and whilch type of damage shound be required.(or ignored).")]
    4.     public class TakeDamageEvent : FsmStateAction
    5.     {
    6.         [Tooltip("The actor that was damaged")]
    7.         [RequiredField]
    8.         public FsmOwnerDefault m_Originator;
    9.         [Tooltip("Is enable TakeDamage Event.")]
    10.         public FsmBool m_Enabled;
    11.         [RequiredField]
    12.         public FsmEvent m_SendEvent;
    13.         // Temp data hold gameobject.
    14.         private GameObject originatorGo;
    15.         private DamageableManager damageable;
    16.  
    17.         //  Search Damge Types for the specified damage type.
    18.         public bool IsValidDamageType (DamageType inDamageType)
    19.         {
    20.             // Check Damage Type is it an damage type or Ignored type .
    21.             return true;
    22.         }
    23.  
    24.         // Damageable Component(Recevier) Trigger this event on Hit by Damager gameObject.
    25.         void HandleDamage (TakeHitInfo hitInfo)
    26.         {
    27.             if (originatorGo == null || m_Enabled.Value == false ||
    28.                 !IsValidDamageType (hitInfo.DamageType)  || // PlayerOnly
    29.                 hitInfo.InstigatedBy == null )
    30.             {
    31.                 return;
    32.             }
    33.  
    34.             if ( m_SendEvent != null )
    35.             {
    36.                 Fsm.Event(m_SendEvent);
    37.             }
    38.         }
    39.  
    40.         public override void Reset ()
    41.         {
    42.             m_Originator = null;
    43.             m_Enabled = true;
    44.  
    45.             m_SendEvent = null;
    46.         }
    47.  
    48.         public override void OnEnter ()
    49.         {
    50.             // Subscribe TakeDamage Event from Owner.
    51.             originatorGo = m_Originator.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : m_Originator.GameObject.Value;
    52.             damageable = originatorGo.GetComponent<DamageableManager> ();
    53.             damageable.Event_TakeDamge += HandleDamage;
    54.         }
    55.  
    56.         public override void OnExit()
    57.         {
    58.             damageable.Event_TakeDamge -= HandleDamage;
    59.         }
    60.     }
     
    Last edited: Feb 19, 2011
  5. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    There really should be a generic way to attach data to an fsm event without using a custom action. So the next update will have these actions: Set Event Data and Get Event Info

    These should make it a lot easier for FSMs to communicate without having to know too much about each other (i.e., their variable names). There will probably still be cases where you need a custom action, but the generic event data should cover most use cases.
     
  6. ROCFriesePoort

    ROCFriesePoort

    Joined:
    Mar 27, 2009
    Posts:
    107
    I hope that it means that the designer can adjust Variables within the Inspector. We still use our scripts, an unified window (the Inspector) were all the variables can be controlled would be great!
     
  7. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    Hello again, i'm back to bother you once more, probably not the last ^^

    Ok since i last posted i've been attempting to recreate this script in playMaker

    Code (csharp):
    1. var go_next_spawn_point : GameObject;
    2.  
    3. private var v3_next_spawn_point : Vector3;
    4.  
    5. function Start() {
    6.     v3_next_spawn_point = go_next_spawn_point.transform.position;
    7. }
    8.  
    9. function OnTriggerEnter(other : Collider) {
    10.     if (other.name == "Sphere") {
    11.       var go_Sphere : GameObject;
    12.       go_Sphere   = other.gameObject;
    13.       go_Sphere.transform.position = v3_next_spawn_point;
    14.     }
    15. }
    I don't want to recreate it exactly as it shows there but would like to define a prefab for "teleporting" rather than an object within the scene.

    I've tried quite a few different actions in hope for the result i'm looking for but i've only managed to get the sphere to teleport to the very bottom of the screen.
     
  8. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Try this:

    Get the position of the spawn point using GetPosition
    Store this position in a Vector3 variable. E.g., spawnPos.
    Set the sphere to this position using SetPosition.
    Use World coordinates in both actions.
     
  9. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @Frido - Yup. First pass will let you expose any FSM variable in the Inspector. You can also set a tooltip. This should provide a nice "black box" interface for an FSM when you're not interested in the internal details...
     
  10. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    Ok so i've made a custom event, put a Trigger Event on the first state and GetPosition and SetPosition on the second state but all that seems to happen is the sphere is destroyed and a new one spawns which nothing happens to when it collides with the trigger.

    Perhaps i'm doing something wrong with the other variables?
     
  11. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Do you have the variables reversed...?

    I'm guessing you want to get the position of MPExit, store it in spawnPos. And set the position of the Sphere to spawnPos...

    If the FSM is on the sphere, you can also leave Set Position Game Object as Use Owner.
     
  12. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    Yeah i think that's what i'm trying to do
     
  13. Alex-Chouls

    Alex-Chouls

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

    Release notes: here

    Highlights: Get/Set Event Data; Expose variables in the PlayMakerFSM Inspector; Browse buttons for FsmName, Events, and Variables in State Machine Actions.

    This will be the 1.0 release build unless you guys find any show-stopping bugs! Working on a few more samples in the meantime...
     
  14. ROCFriesePoort

    ROCFriesePoort

    Joined:
    Mar 27, 2009
    Posts:
    107
    I'm sold! This is a true release version! :) Everything we need is available; CharacterControl, DebugLine, Expose variables.
     
  15. maart

    maart

    Joined:
    Aug 3, 2010
    Posts:
    82
    the GetAxisVectorTest runs choppy, (it has lag) used to run smooth with rc4
     
  16. larvantholos

    larvantholos

    Joined:
    Oct 29, 2009
    Posts:
    668
    Quick question.

    I can create variables. I can set their state with the state machine.
    Can I have those variables saved once set, into a state I can later recall, edit, and modify or do these states only persist as long as the script/game is active?
     
  17. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @larvantholos - You can set their initial default value, but values set by the state machine are temporary. Are you asking to save values that you tweak while playing the game? Or to save states that you edit while playing? You could try Copying a state while the game is running, and pasting it when the game is stopped - haven't tried this yet so don't know if it will work!! Or do you need to make save games? I will be making PlayerPrefs actions that will let you save/load variables.

    @Maart - Thanks, I'll look into it. Just out of curiosity, does RC4 still run smooth for you? Did you upgrade to 3.2 in between?

    @Frido - Cool! Found a couple of small bugs, but I think it's very close!
     
  18. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @Maart - Another question: Is it choppy with the editor window closed? Or just with the editor window open?
     
  19. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    You don't need to convert one page at a time: the PDF printer just prints all the doc as you prefer (also you can split it and print chunks of your doc, like different chapters into different files and link them, it really works like a real printer, only it outputs a PDF file) so if you want you can print it as PDF in a single file with just a couple of clicks :)
     
  20. maart

    maart

    Joined:
    Aug 3, 2010
    Posts:
    82
    yes I updated to 3.2 in between. removed my previous project and did a "re-install" of rc5 to a fresh directory and it seems to run smooth now.
    loving the product so far!
     
  21. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    OK I'm back home now :D the problem with this is that I'm not having the scene objects viewable in any way, only the prefabs are shown up in the pop up window, so I can't select cubbo at all but only see CUBBO.

    And before you ask: only the ASSETS tab appears on the pop up window :D
     
    Last edited: Feb 21, 2011
  22. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    You have to drag the scene object from the Hierarchy into the Game Object field. I think scene objects used to show in the browser, but for some reason they don't any more... not sure if this is a Unity bug...
     
  23. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @Maart - Cool! I do notice some occasional choppiness in Unity, but it doesn't seem to be tied to Playmaker as far as I can tell... most of the time, it seems to be some background windows process... But if you do find some Playmaker related choppiness don't hesitate to let me know!
     
  24. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Ahhh works :D thank you man... going on with experiments :D
     
  25. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    @alexchouls - Ok yesterday was not my best day for dealing with this, so i've made some changes based on what you said, after thinking about it that makes sense but all that seems to happen is the sphere is ported to the same random position when it enters the trigger.
     
  26. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Are you trying to select a random spawn point?

    Take a look at Select Random Game Object

    Fill it in with potential spawn points and store the result in a selectedSpawnPoint variable. Then use that in Get Position...
     
  27. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    Nope i'm trying to select a certain spawn point.
     
  28. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    So is the position wrong? Check Debug and look at the coordinates... Make sure you're using world coordinates in both get and set actions.

    If everything seems setup correctly, send me the scene and I'll take a look at it. There could be a bug somewhere...
     
  29. Voumerus

    Voumerus

    Guest

    Joined:
    Mar 4, 2010
    Posts:
    107
    I've made sure the position of the spawn point is in the correct place and have done everything else suggested, i'll just send you the scene
     
  30. larvantholos

    larvantholos

    Joined:
    Oct 29, 2009
    Posts:
    668
    The short answer is yes (to saving the variables, and having fixed values in game to edit/change) player prefs sounds like it would essentially do that.

    Basically I was thinking it would be useful to have variables I can set permanent values to, so that when I modify those values within the states, I could revert them to the default number, instead of having to remember what it is that default number was within the initial state I set it to.

    I'm thinking of this because I'm trying to create a sort of "battle" system, and while active I want to modify different states of stats within it, some of which will revert back when done - and otherwise if I want to do any sort of level modifiers, it would be based on the original states + the modified numbers or something like that.
     
  31. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    Any news about this? A day seems too long, and it's so close to release!
     
  32. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Just wrapping up the asset store submission and web page... almost there!
     
  33. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @larvantholos - Yeah, PlayerPrefs might do the trick... I'll release PlayerPrefs actions after the initial release. I know at least one beta tester has made their own PlayerPrefs actions, so I'll try to set up that User Actions page on the wiki and see if they want to submit them...
     
  34. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,362
    Hey Alex,
    I've missed few of your last announcements/posts.
    What is the final price tag for PlayMaker?
    And how are the docs regarding custom actions creation?
    Cheers,
     
  35. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    I know you're close to finishing, but can I make a suggestion.

    I think something that will be necessary for any large project will be some place to keep GLOBAL custom events. This could work like the current "Events" area, except that the custom events included in it can be shared throughout all FSMs (and it would be even better if you could categorize the events). They could then be referenced by each FSM.

    This would completely remove some of the problems we are having at current. For example, one of our designers writes Player Moving whereas the other writes PlayerMoving. This has led to a number of unnecessary bugs.

    An implementation of some sort of this system would be VERY appreciated!
     
  36. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    568
    Why is the downloaded project so difficult to open? If I start a new project an import the package all is fine. But if I try to just open the downloaded project so I can reference the sample scenes, I get an error message - multiple library files. A closer look at the project structure shows multiple assets folders, multiple library folders - seems as if there are three sample projects that are meant to be stand alone projects but are all combined into one project.

    I'm just trying to learn from the samples - so please advise - what do I do to just have a project with the sample scenes that loads without errors?

    Thanks, Mitch
     
  37. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @tatoforever - $100. Working on the custom action docs now...

    @RickyBozzy - Great suggestion. Don't worry 1.0 is just a stable release that I can build on. There's lots of stuff I want to add, and better Event management is high on the list... ultimately you should never have to type an event name, and it should be easy to manage all the events in your project.

    @MitchStan - Are you saying you unzip the project, open it in Unity and you get errors? I'm not seeing that here... What error are you getting exactly? When do you get them? When you open the project or when you open a sample scene? There should only be one Library folder in the zip... not sure why you're seeing more. Do you have Unity 3.2 installed?

    EDIT: Just to be clear, are you following the README.txt:
    The Playmaker Beta is a complete Unity Project.
    Unzip the project to your Unity Projects folder then load the project in Unity.
     
    Last edited: Feb 24, 2011
  38. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    568
    Yes - read read me. Yes - have 3.2 installed.

    I get errors of multiple libraries found if I option click Unity and tell it to open the playmaker project. There are ideed multiple library folders in the download. There is PLAYMAKERRC5->PLAYMAKER->LIBRARY and there is also PLAYMAKERRC5->ASSETS->PLAYMAKERSMPLES->TESTLAB->LIBRARY.

    If I double click any of your scene icons in any of your folders in your project, Unity loads and then assets are missing.

    I don't understand the logic of your project folders. I also don't understand what you mean when you say "load the project in Unity." It seems to me that just opening the project should work and also double clicking any scene should work. In my case, neither does.

    I'm on a mac - any helpful thoughts? Thanks in advance.

    Mitch
     
  39. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    I honestly didn't know you could do either of those thing with Unity. Just launch Unity, File-> Open Project, Open Other and select the unzipped project folder.

    But first delete the project folder you have since it should only have one Library. Maybe Unity made another Library folder when you double clicked a scene... The sample folders are organized under 3 main folders each with their own assets. I guess Unity tries to use the first Asset folder it finds if you double click on a scene file to load the project, and that made the second library...?

    I didn't realize Assets was a magic name in this way (I used it in the more generic sense). I'll rename those folders in future releases to avoid confusion...
     
  40. larvantholos

    larvantholos

    Joined:
    Oct 29, 2009
    Posts:
    668
    Actually was having the same issue as mitch stan. It seemed to me that loading the projects, did not load playmaker - I'm not entirely clear on how to setup playmaker so it automaticly loads with the example projects, as everything comes up in errors.
     
  41. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    Try deleting the unzipped folder and start over. Unzip the project. Launch Unity and open the project from File -> Open Project.
     
  42. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    568
    Okay - but what folder do I point it to, in order to open correctly?
    PlaymakerRC5?
    PlaymakerRC5->Playmaker?
    PlaymakerRC5->Playmaker->Assets->Playmaker?
    PlaymakerRC5->Playmaker->Assets->PlaymakerSamples?

    Any of those choices produces an error - multiple libraries. Still not sure what I am supposed to do to open this project without issues. Never encountered this with a Unity project before.

    Your Playmaker utility is way way cool, but the project hierarchy is quite unconventional for Unity. Any thoughts to restructuring the project to conform to the usual straightforward and elegant Unity project structure?

    Mitch
     
  43. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    PlaymakerRC5->Playmaker

    PlaymakerRC5 should not be selectable from File->Open Project (at least here on a pc it isn't).

    The only problem is the name of the Assets folder in each samples directory.

    Delete the unzipped folder. Unzip it. Open Unity. Use File->Open Project and select PlaymakerRC5->Playmaker (the first selectable directory) and all should be fine.

    Future releases will not use the magic folder name "Assets" in the samples directories. Unless things are working differently on a mac (they weren't last time I checked) that is the only problem here... if you have multiple libraries you've already tried to open the "wrong" directory and need to start over (the zip only has one library).
     
  44. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    568
    Okay - thanks - that worked.

    You might want to have all your scenes in a Scene folder and all your meshes in a Meshes folder. I suggest eliminating the folders for the example projects. No need to have those folders if you have your scenes in a Scene folder.

    You should not have a structure where a users runs the risk of opening the wrong directory and therefore creating a extra library folder. I never came across that before in 3+ years of using Unity.

    All that aside - fantastic work on Playmaker. People are going to benefit tremendously for your brilliant work!

    Mitch
     
  45. MaDDoX

    MaDDoX

    Joined:
    Nov 10, 2009
    Posts:
    764
    I'm really anxious for the final release already Alex :) I haven't had time to fiddle much with it yet (although I've watched the tutorials and skimmed thru docs), but that's what I'm interested on the most as a designer so I'll ask straight if it's possible/easy to do.

    Personally as a professional designer with a strong background on balance I hate having to browse through each item changing its variables, it's much easier having it all centralized at a single place and have the option to export it to a text files using commas (CSVs) so if the database is big (typical on RTSes and MMOs) I can simply import it to Excel, arrange and make number analysis as I see fit and export the adjusted values back to the engine without breaking a sweat.

    Hence, I'd like one "GameData" object at the root of the scene, with *all* my main gameplay values there, sometimes in a tree like structure (arrays within arrays). I want this data to be optionally saved/read to an external text file, probably not the prefs one since that's generally for the player's custom data.

    I want this GameData (static, but optimally editable during runtime with the inspector) data to be accessible seamlessly by all FSMs and components in the scene, at any time. Probably a designer-mind question that my coders have their own answers to, I'd just like to hear some opinions about that central-hub approach and how you guys do it.
     
    Last edited: Feb 24, 2011
  46. cmasterenko

    cmasterenko

    Joined:
    Jul 10, 2010
    Posts:
    67
    I love where you're going with the touch events. It sounds great, I'd also like to see accelerometer support for movement and actions and GPS location support if at all possible.
     
  47. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    @MitchStan - Thanks! Sorry about the project hassles - learn something new about Playmaker every day! FWIW, I'm not a big fan of magic folder names. I see a lot of posts trying to figure out the rules for special folders (plugins, editor, gizmos, resources...). Personally would prefer a project file that you can view/edit. Even if you never change it, it's more self explanatory... anyway - it's all fixed in the final release, so glad you caught that problem now!

    @MaDDoX - Great question! I've worked on projects where having a central spreadsheet was a life saver. Sounds like an extension somebody should write for Unity... You can do some of what you describe in Playmaker, but it's not built around that idea. It's more of an extension of the Unity inspector panel idea, with modular actions that you can turn on/off with state machines. But would be a cool option in Playmaker if there's enough demand...

    @cmasterenko - The iOS actions aren't quite ready for the initial release but should be available shortly after as a free update... I want to get them right, with good sample scenes. There will be accelerometer actions, but have to research GPS support...
     
  48. DJAZLAR

    DJAZLAR

    Joined:
    Feb 18, 2011
    Posts:
    37
    Hi there im having a spot of trouble at the moment . I have got variables i am using in fsm on an object and im not the best at scripting, is there an easy explanation on how to use a particular variable in my own script from a fsm.

    I have already looked over in your earlier post about this and trid to understand how to do it from that and still having no luck . Its the only thing holding me back at the moment.
     
  49. Alex-Chouls

    Alex-Chouls

    Joined:
    Mar 24, 2009
    Posts:
    2,644
    I assume you found this code earlier in the thread:

    Code (csharp):
    1. using UnityEngine;
    2. using HutongGames.PlayMaker;
    3.  
    4. public class UseFSM : MonoBehaviour
    5. {
    6.     public PlayMakerFSM behavior;
    7.    
    8.     void Update ()
    9.     {
    10.         // getting named fsm variables
    11.         FsmFloat test = behavior.FsmVariables.GetFsmFloat("test");
    12.        
    13.         // setting named fsm variables
    14.         test.Value = 0.5f;
    15.        
    16.         // sending events
    17.         behavior.Fsm.Event("test");
    18.     }
    19. }
    With this example, you would just drag a PlayMakerFSM component onto the Behavior field then access its variables as shown. How far did you get?
     
  50. DJAZLAR

    DJAZLAR

    Joined:
    Feb 18, 2011
    Posts:
    37
    I have an Ai mob as a prefab with a FSM attached to it and i dragged this onto the behaviour field and i want to use say as an example the variable "collected" which I used to keep track of items collected to be accessed by a script for displaying the scoring system.