playMaker

Author Topic: UnitySteer  (Read 2287 times)

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
UnitySteer
« on: February 13, 2014, 09:47:34 PM »
Is anyone out there using UnitySteer with Playmaker?  If so, are you able to use the Get Property and Set Property effectively with all the different UnitySteer components?  I'm using UnitySteer 2.7 and feel like I need to create my own Custom Actions, but I really want to avoid this.

Below is a custom action I created for use with SteerForTarget so that I can Set the Target via Playmaker (good for seeking/finding something).
Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("UnitySteer")]
[Tooltip("Using UnitySteer 2.7.  This Action sets the target on the SteerForTarget Script.  " +
"As the Target on SteerForTarget is actually a Transform, this converts the GameObject component " +
"to a transform for UnitySteer to utilize.  This action is useful so that you can have your FSM" +
"change the target via your Playmaker logic.")]
public class SteerForTargetSetTarget : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(SteerForTarget))]
public FsmOwnerDefault gameObject;
private GameObject trans;
[ActionSection("Result")]

[Tooltip("The new target")]
public FsmGameObject target;

[Tooltip("Repeat every frame. Useful when value is subject to change over time.")]
public bool everyFrame;

SteerForTarget Target;

public override void Reset()
{
gameObject = null;
target = null;
trans=null;
everyFrame=false;
}

public override void OnEnter()
{
//Get the game object this FSM is on
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
Finish();
return;
}
//Get the target from SteerForTarget UnitySteer Script
Target=go.GetComponent<SteerForTarget>();
if (Target == null)
{
Finish();
return;
}

setTarget();

if (!everyFrame)
{
Finish();
}
}

void setTarget()
{
trans=target.Value;
Target.Target=trans.transform;
}

}
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14593
  • Official Playmaker Support
    • View Profile
Re: UnitySteer
« Reply #1 on: February 13, 2014, 09:51:20 PM »
Hi,

 you can use set get property on simple public variables, but if it's a special class within internal public variables, then yes, you'll need custom actions...

what component in particular do you have problem with?

bye,

 Jean

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: UnitySteer
« Reply #2 on: February 14, 2014, 05:41:09 AM »
It's not that I have a problem.  I'm wanting to use some of the different UnitySteer scripts in-game and change the Target on the fly whenever I need to.  I know how to make all the UnitySteer pieces work together and I'm trying to avoid creating a bunch of C# scripts to "talk" to it.  I'm only trying to influence the "public" variables that can be set in the inspector because I want to change them "in-game" based on outcomes.  For instance, if a target dies, I want to set a new target OR if there are no targets then I'm going to turn off that script via playmaker (enable behavior).

There's a ton of UnitySteer scripts that I might want to access in this manner in the SteerFor (Target, Tether - uses vector3, cohesion, alignment, separation, evasion, pursuit, and so on).  Each might have a slight variance (like Tether uses Vector3s instead of a gameobject).  All the "Targets" are actually "Transforms" so you have to convert to/from a FSMGameObject.

Make sense?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: UnitySteer
« Reply #3 on: February 14, 2014, 07:55:46 AM »
I've glanced at the scripts but more for trying to make new PM driven systems from their algorithms. I hadn't tried actually using it and reaching in to change things with PM.

Like Jean said though, it should be pretty straightforward to use get component and get/set property to change variables on the fly per script as long as the scripts are using simple public variables. If you're needing to turn gameObjects into transform variables you'll have to do that separately of course and maybe it makes sense to have a custom action to handle those types of scenarios.

I asked Ricardo if he was interested in making actions for it but he isn't using PM and doesn't really have much reason to do it. The whole system is free anyway, so I can't blame him. If you're going to look into making actions for it then let me know and I'll help you out. I ended up making my own solution but UnitySteer actions would be really great to have around here.

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: UnitySteer
« Reply #4 on: February 14, 2014, 12:21:41 PM »
I plan on just creating the ones I need specifcally.  There aren't many things that even need to change on the fly.  Mainly just getting/setting the public values, but nothing currently in PM can do that (or maybe I don't know what I'm doing or how to use it correctly).  So, I plan to just create ones I need as I go.  I will also create myself some temporary ones for any RAIN actions I need if I tie the two together.

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: UnitySteer
« Reply #5 on: February 21, 2014, 08:18:42 PM »
Wow, I was not using Get/Set property correctly.  Thank you so much for creating a Video that actually shows how to use this correctly.  You have now shown me how to use this to tie this together to ANY SCRIPT I have!  I am so extremely excited!  I have already tied this into UnitySteer and it works amazing!  I should be able to also link this into RAIN and make this all talk together much faster than creating my own C# scripts (which I have done by the way).

Below is Your video that I am refering to. Wow!  Wish I had seen this a year ago!!!