Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Integrating PlayMaker into a project

Discussion in 'General Discussion' started by Tomnnn, Dec 22, 2014.

  1. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I saw PlayMaker on sale. I visited their web page and saw that The Forest and even Hearthstone use it for something! I saw that it supports writing your own code to put into the action editor visual thing. That basically forced me to buy it, because I love state machines & modular code.

    I'm curious, anyone who has bought it, how are you using it? The Forest uses it for their a.i. and hearthstone uses it for events (whatever that means), and so far I've used it to make a light switch, running a custom action to take a reference to an object and disable the first child (which was a light in my project).

    I can see how it would be great for a.i., and it's meant to be a solution for visually making a state machine, so what have you used it for?
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381
    I've made this stuff





    Those vids represent gameplay 95% made in Playmaker without scripting. The stuff I have actually bothered to script for convenience... I just made as custom actions so I could have them in available as actions in the FSM editor... I've also made a physics driven spaceship pilot AI that avoids obstacles and leads targets by inputting forces on its ship.

    Making custom actions is pretty straightforward. There is an API reference and some examples on the Wiki. It's a pretty robust tool and I think a lot of people are unaware of the more advanced things you can do with it since it's pretty overwhelming to begin working with. Making it just do random stuff around the game is awesome, takes seconds to setup flickering lights, triggers, enemy spawners, whatever.
     
    Ryiah and Alex-Chouls like this.
  3. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    I use it to set up triggers and do simple animations with itween, change cameras to a closeup, and enable or disable scripts or other components. It works really good most of the time, then it doesn't and I have to write code and work around it or with it. Haven't needed AI yet. I think the best part of it for me is the "finished" event. That's kind of pain when you are coding.
     
  4. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    @LaneFox Wow, that's a lot of work with just playmaker. I guess I'll try making a game with >90% playmaker just to see what it's like.

    @fire7side so far I agree with that finished event. Is there a tween option to use physics so you don't move through things?
     
  5. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,973
    I decided to ditch my normal methods of coding and try using PlayMaker for this current game I'm working on, just to see how it goes. I'd always thought of it as something that wouldn't be useful since I already know how to code, so I ignored it. Then I read a few reviews from people who knew how to code and liked it anyway, so I picked it up (at full price and then it went on sale shortly afterward - story of my life).

    It's awesome and not so awesome at the same time. I've been working with it for about four months now and it is absolutely amazing for setting up and testing the flow of the system. So easy to just move things around and try different ideas without having to hand code them and wait for a compile. It is seriously really, really cool. And fun.

    What I've done is to use it for setting up the flow and basically having it call on my coded scripts for anything fairly complex. The tiny things, like activating a game object or fading in a camera, I use PlayMaker for. No sense writing code when it can do it with a couple of button clicks. So the majority of my latest project is pure C# and I'm using PlayMaker to prototype ideas and set the flow as I go. So far it's been great with only a few hiccups.

    With that said, once this new game is finished I plan to take everything that I've set up in PlayMaker and transfer it to C# code. I don't care for the idea that so much of my game's underlying code base relies on a third party asset. I'll definitely use it again for the next game in the same way.
     
  6. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    @Ony that thing about the sale was a sad story.

    What's wrong with running your game as a series of managed finite state machines? :D
     
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,071
    You can do FSMs easily in C# too. :p
     
  8. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Just a little funny (Though that actually is the reason I don't use this kind of stuff much)
     
  9. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,973
    I know. I understand that it doesn't make much sense given that Unity itself is a third party tool, but I just like my code to be in a form I can easily back up, easily go back to later, and easily do whatever I want with without it being tied to a third-party tool. Code is text. I like it like that.
     
  10. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    @Tomnnn I just use it for opening doors and such. I'm pretty sure the colliders still work. I kind of feel that same way about text code, but I doubt I'll go back and make changes since I just use it for smaller type things. As far as writing my own fsm, it wouldn't have all the debug tools or built in actions, which is the whole point.
     
  11. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    When I think about it, I usually implement menus as a finite state machine. But it's kind of fun to use the visual editor, heh.

    In most cases I do end up writing my own code, I just hook it up in the editor. It's (as stated above) so much fun :D It's nice to focus on design for once. I started and finished a stupid shooting game today, and the only code I wrote (besides some data stored in monobehaviors) was for changing the size of the mouse cursor texture. Here's something I made for a shooter where you run around a graveyard :)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. namespace HutongGames.PlayMaker.Actions
    5. {
    6.     [ActionCategory("_Custom")]
    7.     public class InstantiateWithPoints : FsmStateAction
    8.     {
    9.         [Tooltip("An empty transform that contains a number of spawn points")]
    10.         public Transform spawn_point_holder;
    11.         public GameObject prefab;
    12.  
    13.         public override void OnEnter ()
    14.         {
    15.             selectAndSpawn ();
    16.             Finish ();
    17.         }
    18.  
    19.         void selectAndSpawn()
    20.         {
    21.             GameObject g = GameObject.Instantiate (prefab,
    22.                                     spawn_point_holder.GetChild (Random.Range(0,spawn_point_holder.childCount)).position,
    23.                                     Quaternion.Euler(0,Random.Range(-180.0f, 180.0f),0)) as GameObject;
    24.             /*keep hierarchy clean*/
    25.             g.transform.parent = spawn_point_holder;
    26.         }
    27.  
    28.     }
    29. }
    @fire7side a door is... closed -> opening -> open -> closing -> closed? haha, it's fun to conceptualize state machines.