playMaker

Author Topic: Custom action is not running[SOLVED]  (Read 709 times)

Censureret

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Custom action is not running[SOLVED]
« on: April 24, 2017, 01:46:30 AM »
So i am trying to create an action that can talk with "ooties motion controller"

However i have a problem:

I have the following script:

 
Code: [Select]
using com.ootii.Actors.AnimationControllers;

using UnityEngine;

 

namespace HutongGames.PlayMaker.Actions

{

    [ActionCategory(ActionCategory.ScriptControl)]

    [Tooltip("Allows you to use Ooties motioncontroller")]

 

    // the class must match the name of the action

    // if the action is named missleAction then that should be the name of the class

    public class MotionAction : FsmStateAction

    {

 

        private MotionControllerMotion lMotion = null;

        private MotionController mController = null;

        [RequiredField]

       

 

        public FsmOwnerDefault gameObject;

        public FsmBool everyFrame;

 

        public override void Reset()

        {

            Debug.Log("Here");

            //its good practice to set your var to null at start

            mController = null;

            lMotion = null;

 

        }

 

        public override void OnEnter()

        {

 

            Debug.Log("Enter");

            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            mController = go.GetComponent<MotionController>();

 

        }

 

        public override void OnUpdate()

        {

 

            Debug.Log("Update");

            if (everyFrame.Value)

            {

                DoTheMagic();

            }

        }

 

        //Name your method here

        void DoTheMagic()

        {

 

            Debug.Log("Magic");

            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go == null)

            {

                return;

            }

 

            lMotion = mController.GetMotion(100, "Death");

            mController.ActivateMotion(lMotion);

        }

 

    }

Ive added an image of my FSM as an attachment.

I get no errors in the console but it seems that the code is not running. None of the debug messages are being logged to the console.

I have also tried to debug it however even if I place breakpoints in the whole script it does not break.

My question is can you see what ive done wrong?
« Last Edit: April 26, 2017, 03:55:03 AM by jeanfabre »

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 695
    • View Profile
Re: Custom action is not running
« Reply #1 on: April 24, 2017, 03:52:51 AM »
Not sure I completely understand your scripts goal.

You are trying to get a value from com.ootii.Actors.AnimationControllers, into playmaker, correct?

1. I see you havent added any new FSMvariables to your script. It only has FSMvariable for gameobject (the location of the script) and everyframe. You need some kind of FSMvariable to get values in or out of playmaker.

2. You don't need to null the variables at the top (although it is not script breaking).

Code: [Select]
private MotionControllerMotion lMotion = null;
private MotionController mController = null;

3. There are some camera controller scripts by mdot strange https://github.com/mdotstrange/CameraControllerPlaymakerActions

Censureret

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Custom action is not running
« Reply #2 on: April 24, 2017, 04:21:46 AM »
Well this is just an example script it is suppose to run a motion from a motion controller.

But the script doesn't run it seems, that is my issue.

 
Code: [Select]
         
lMotion = mController.GetMotion(100, "Death");
mController.ActivateMotion(lMotion);

The above could should "hack" into the motionController and play the motion "Death".

Rupe

  • Playmaker Newbie
  • *
  • Posts: 7
    • View Profile
Re: Custom action is not running
« Reply #3 on: April 24, 2017, 04:59:46 AM »
Have you checked that the FSM is actually running, that it is getting to the state that's using your action?

Censureret

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Custom action is not running
« Reply #4 on: April 24, 2017, 05:31:31 AM »
Yes and it does. Again with no errors in the console

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14198
  • Official Playmaker Support
    • View Profile
Re: Custom action is not running
« Reply #5 on: April 26, 2017, 01:09:57 AM »
Hi,

 yeah, it's odd, first thing I would do is put appropriate logs int he Unity console to be absolutly sure you are calling something, when you are sure you do, you can rule out the action, and concentrate on why calling this api doesnt' work. you log before a potential return, this might be the problem, make sure you log one ling above the call that is supposed to do something,.


use UnityEngine.Debug.Log() inside action so that they get outputed inside the Unity console, else it's logged inside the PlayMaker log.


Bye,

 Jean

Censureret

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Custom action is not running
« Reply #6 on: April 26, 2017, 01:54:30 AM »
Hey Thank you so much for your response.

i actually fixed this issue. The problem was that in Visual studio 2017 you have to click on a button called "Apply to unity" before it can be attached to the game!