playMaker

Author Topic: A Sharing FSM thread?  (Read 7576 times)

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
A Sharing FSM thread?
« on: October 14, 2011, 08:42:09 AM »
So, i was curious how many would be up for a "let's share how we did it" thread where we post our FSMs to achieve various tasks that are a little more on the complex side? i've been working on some but i know that there are some areas where i could learn to do better.

though, not meant as a "copy this into your game to do X" kinda thing, more along the lines of exploring how all the actions can come together to make the behaviors we're aiming for. (though i'm sure some will probably take without contributing, but i guess that's unavoidable.)

emphasis is on sharing how we do specific actions. because i know that i could definately use some help in some but i've managed to crack others... also as a means of maybe checking out our FSMs to see if they can be streamlined.

I think it would be a way of increasing our respective productivity by learning how to apply ourselves with Playmaker to reach the goals we're hoping for a lot sooner than if we were to all do it on our lonesome.

i know there are tutorials out there but i'd think this would be more about just posting the templates and such.

so, good idea? bad idea? if so or not, why?

ByronNilsson

  • Playmaker Newbie
  • *
  • Posts: 18
    • View Profile
Re: A Sharing FSM thread?
« Reply #1 on: October 14, 2011, 11:54:52 AM »
Great idea, myself being a traditional programmer can work the technical side, but need a bit of a nudge on the concepts/ideas for new and innovative concepts.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3207
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: A Sharing FSM thread?
« Reply #2 on: October 14, 2011, 08:59:50 PM »
I agree, this is a great idea.

A couple of related thoughts:

  • It would be great to ship Playmaker with a whole bunch of default templates. Hopefully people who share FSMs on this thread would be interested in submitting them as templates...
  • Communal projects would be a great way to learn Playmaker and identify/implement new actions and templates. For example, take a well known game concept and implement it in Playmaker. The resulting project could then be shipped with Playmaker. I might try to kick one of these off soon...

« Last Edit: October 14, 2011, 09:12:51 PM by alexchouls »

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: A Sharing FSM thread?
« Reply #3 on: October 15, 2011, 05:29:27 AM »
hmm... so, that being said, if there's a community focus on making templates, what sort of templates do y'all think we should work on?

maybe a brainstorming session and then a community vote on the ideas? or just a sort of "grab bag" kinda thing where people grab an idea, make it and then submit it?

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: A Sharing FSM thread?
« Reply #4 on: October 19, 2011, 11:51:43 AM »
i've got a couple templates that i am able to share, just working through some upload issues on my end before i can post them. one is a weapon management system (6 weapons total using either 1-6 on the keyboard or the scroll wheel to cycle through and updates a cube that i have parented to the camera to denote the HUD system that shows the weapon equipped.) another is a basic monster spawning template (spawns up to 25 monsters randomly placed within a 10x10 grid space and deletes the spawner after completion, also spawns a little sparkly effect when each monster is created to kinda give it a feel of something magical.)

Darnen

  • Playmaker Newbie
  • *
  • Posts: 13
    • View Profile
Re: A Sharing FSM thread?
« Reply #5 on: November 20, 2011, 06:22:10 PM »
That is awesome, I would not mind at all contributing to this. I am working on a decent AI patrol system that I could upload once I have got it working properly.

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: A Sharing FSM thread?
« Reply #6 on: December 19, 2011, 03:25:07 PM »
http://fantasy21.comyr.com/Firing_Template.asset

needs a little explanation to be used. This is to control the direction the player is facing dependent on the left mouse button being held down. this can be used for things like a diablo-style top down interface with the casting/firing/attacking being tied to the mouse button.

create object, i use "player matrix" but the name is not important. make it move much like the 3rd person controller tutorial outlines (but do not add in the "smooth look at direction" action as the child should handle that.) i used an empty game object. inside it, drop in the geometry and add this template to the geometry (the "player matrix"'s child.)

from there, in the "get FSM vector3" action, drag on the "player matrix" (the parent object) as a specified object, set up the rest (i use "movement" twice but you should be able to figure that out by making them different names.)

i was banging my head on the wall trying to figure it out when it just clicked when i was browsing some of the states.

i've got another one coming but i want to make sure it's saved properly first. if you need any help with this template, please let me know and i'll do what i can to help.
« Last Edit: December 19, 2011, 03:46:28 PM by Red »

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: A Sharing FSM thread?
« Reply #7 on: December 19, 2011, 04:49:06 PM »
http://fantasy21.comyr.com/Monster_Spawner.asset

Simple enough, create an object to use as the trigger to link this up to and drag the monster prefab to the appropriate spot. change "count" to note how many monsters you want spawned and adjust the X and Z values generated to suit your needs (if you want them to be from -x to x, i suggest adjusting the "int add" so that 1/2 of x is there.)

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: A Sharing FSM thread?
« Reply #8 on: December 25, 2011, 07:52:06 AM »
Two more templates, both are required together on empty game objects to work.

http://fantasy21.comyr.com/Weapon_Tracker.asset
http://fantasy21.comyr.com/Weapon_Selector.asset

it's limited to only 6 weapons but you can use either 1-6 on the keyboard or the scroll wheel to select a weapon. also, you can toggle between a primary and a secondary weapon by clicking the right mouse button. the aim was to go for a sort of interface much like bioshock in it's simplicity.

this also requires a third object if you want to make a weapon indicator to show what weapon is currently highlighted but it shouldn't be hard to figure out what that is and how to set it up. both weapons start off as the first weapon being selected.

the tracker is handy for dynamically adding in wether a weapon is collected/selectable by toggling the boolean values to true or false.

i know it looks ugly and kinda like the FSM version of spaghetti code but it works. if you want to improve on it, feel free. though, if you do use one of my templates in a professional game, a thank-you would be nice. that being said, if you wish to improve it or make it more streamlined, please please please post the template so that i can learn what you did to improve it (we're all in it to learn, eh?)
« Last Edit: December 25, 2011, 04:06:33 PM by Red »

Tijmen

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: A Sharing FSM thread?
« Reply #9 on: March 16, 2012, 03:16:13 AM »
Since i couldnt find any action that uses the new NavMesh i've created a fairly simple action for a NavMeshAgent to walk to any GameObject. It also has an option to wait before the Actor has reached its goal, something that is not as intuitive as you'd like in Unity.

Code: [Select]
using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;

[ActionCategory(ActionCategory.NavMesh)]
[Tooltip("Navigates an agent to an object.")]
public class NavigateToAction : FsmStateAction
{
    [RequiredField]
    [Tooltip("Character to move")]
    public NavMeshAgent Origin;
    [RequiredField]
    [Tooltip("Game Object to move to")]
    public GameObject Target;

    [Tooltip("When checked the execution will stop until the origin has reached the target")]
    public bool Blocking;

    public override void Reset()
    {
        Origin = null;
        Target = null;
        Blocking = false;
    }

    public override void OnEnter()
    {
        Origin.SetDestination(Target.transform.position);
               
        if (!Blocking)
            Finish();       
    }

    public override void OnUpdate()
    {
        if (Blocking && Mathf.Approximately(0, Origin.remainingDistance))
            Finish();
    }
}

Any feedback is appreciated :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: A Sharing FSM thread?
« Reply #10 on: March 16, 2012, 03:57:15 AM »
Hi,

  NavMesh actions are actually under review and will be soon available.

 meanwhile, your set Destination is good, but you should use the remainingDistance with care, because it's definitly not the actual physical distance that one could expect to have, it's actually very obscur the way they did it...

if for example, your destination is outside the navmesh area, you will never reach the destination, the agent will never move outside the navmesh area. YET the remaining distance will eventually reach 0... go figure...

 So I would suggest that you actually find the distance between the agent and the destination manually, then you will have a much more accurate mathematical representation of the remaining distance.

Bye,

 Jean

Tijmen

  • Playmaker Newbie
  • *
  • Posts: 2
    • View Profile
Re: A Sharing FSM thread?
« Reply #11 on: March 16, 2012, 05:33:41 AM »
Its rather silly Unity doesnt just expose a boolean if the actor has reached its destination in my opinion...
But this solution will do for us, until Playmaker releases those new actions :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: A Sharing FSM thread?
« Reply #12 on: March 22, 2012, 05:17:51 AM »
hi,

 Yes, you will find anyway that pathfinding is not the ideal solution... while being very powerful on paper, in practice, it is involving to build a proper system... Agents will behavior very weirdly if things gets in their way, or if speed and accelareation is edited to some "exotic" higher values ( you will not have a storming agent behave properly for example...). Agent behavior around destination is "stupid", instead of stopping, they just keep trying... which feels very wrong. At least a setting for this would be good...

so basically... a lot work ahead for non standard agents... be it with or without Playmaker.

We are definitly far from crowd behavior wonderness that you can find in max and other 3d soft... I don't understand why they did not go for proper crowd behaviors... pathfinding and agents seems like a trial waiting for more.

Bye,

 Jean

Red

  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: A Sharing FSM thread?
« Reply #13 on: October 09, 2012, 03:31:24 PM »
http://fantasy21.comyr.com/Handgun%20Template.asset

Hey there, thought i'd post a template i've been using... this is a base i've been using for line-of-sight weapons in the game.

if you want to check it out, go for it... it's also helpful in showing how to set up some basic flow i'd think.

to note, the actions should be self-explanatory but the "is enemy" action where it calculates the damage to be assigned and sends the event to the enemy it's hit might be a little confusing if i left the settings as empty, so i left them in so you can get a feel for how i've been doing it.

it seems more beastly and complicated than it really is... so, if you need an assist and clicking through the system one state at a time doesn't work for you, feel free to ask.

yes, i know, this is a necro thread but i haven't seen a template sharing thread around.

let me know if you have any issues, i'll try and help out if i can.

how i use it is i drop that on an empty game object that has a spawn-point in it's heirarchy (so that the raycast knows where the point to fire from) and that game object is oriented as needed... i think this could be used on an FPS system as well but it might need some finagling to get it to work well for that scheme (the scheme i have set up is a third-person overhead/isometric shooter type game.)
« Last Edit: October 09, 2012, 03:43:07 PM by Red »

lildragn

  • Playmaker Newbie
  • *
  • Posts: 37
    • View Profile
    • Videogame-art.com
Re: A Sharing FSM thread?
« Reply #14 on: October 09, 2012, 05:24:36 PM »
Thanks Red, will definitely look at this. Btw this thread should definitely be a sticky :) It can become very handy. I plan to offer up some templates/packages as well once I become more proficient with PM.

~t