playMaker

Author Topic: Transform Has Changed  (Read 4587 times)

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Transform Has Changed
« 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.
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Transform Has Changed
« Reply #1 on: August 15, 2015, 03:14:59 AM »
cool.. thx for all your actions..  :D

can they be found on the ecosystem?

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Transform Has Changed
« Reply #2 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?
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Transform Has Changed
« Reply #3 on: August 16, 2015, 05:49:57 AM »
Hi,
i can do it for you

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Transform Has Changed
« Reply #4 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 :)
« Last Edit: August 16, 2015, 08:00:45 AM by djaydino »

sebaslive

  • Hero Member
  • *****
  • Posts: 572
    • Frame Tale Studios
Re: Transform Has Changed
« Reply #5 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
All my VR games use Steam VR Playmaker Toolkit: http://u3d.as/u20
And Oculus Touch Playmaker Toolkit: http://u3d.as/QT5


Follow me @sebasRez

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Transform Has Changed
« Reply #6 on: August 17, 2015, 02:46:31 PM »
Np,
i have added it to the EcoSystem