Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: sebaslive on August 14, 2015, 01:16:33 PM

Title: Transform Has Changed
Post by: sebaslive on August 14, 2015, 01:16:33 PM
If your transform has changed in any way this will set the bool to true, if it is still it will set your bool to false.

Excellent way to tell when an object is in motion.
Title: Re: Transform Has Changed
Post by: dudebxl on August 15, 2015, 03:14:59 AM
cool.. thx for all your actions..  :D

can they be found on the ecosystem?
Title: Re: Transform Has Changed
Post by: sebaslive on August 15, 2015, 03:11:15 PM
I don't think so? Does Jean put them in manually or is it something I have to do?
Title: Re: Transform Has Changed
Post by: djaydino on August 16, 2015, 05:49:57 AM
Hi,
i can do it for you
Title: Re: Transform Has Changed
Post by: djaydino on August 16, 2015, 07:58:28 AM
Hi,
Your action was not working correctly, when the action starts it sends a true value and then goes to false.
so i updated it so it works correctly, also i added a send event and removed the every frame option (the action can not work if not every frame)

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2015. All rights reserved.
// Action made by : Sebaslive
// Forum link : http://hutonggames.com/playmakerforum/index.php?topic=10953.0
// Edited by : DjayDino
/*--- __ECO__ __ACTION__ ---*/

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Transform)]
[Tooltip("Sets a bool to true if Transform has changed.")]
public class TransformHasChanged : FsmStateAction
{
[RequiredField]
[Tooltip("The GameObject to check if transform has changed.")]
public FsmOwnerDefault gameObject;
[UIHint(UIHint.Variable)]
public FsmBool storeResult;
public FsmEvent changedEvent;

public override void Reset()
{
gameObject = null;
storeResult = null;
changedEvent = null;
}

public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
go.transform.hasChanged = false;
            DoTransformHasChanged();
}

public override void OnUpdate()
{
DoTransformHasChanged();
}

        void DoTransformHasChanged()
{
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null) return;
            if (go.transform.hasChanged)
            {
if (storeResult != null)
{
                storeResult.Value = true;
}
Fsm.Event(changedEvent);
            }
           
            if (!go.transform.hasChanged)
            {
                storeResult.Value = false;
            }
            go.transform.hasChanged = false;
}

}
}


i will add this to the EcoSystem when you are ok with it :)
Title: Re: Transform Has Changed
Post by: sebaslive on August 17, 2015, 08:51:29 AM
Oh thanks for the help, and you are right about the every frame, I always tested it with that option on. I will double check all the options next time  :P
Title: Re: Transform Has Changed
Post by: djaydino on August 17, 2015, 02:46:31 PM
Np,
i have added it to the EcoSystem