playMaker

Author Topic: Playmaker Custom Actions  (Read 1259 times)

Wulfborn

  • Playmaker Newbie
  • *
  • Posts: 4
Playmaker Custom Actions
« on: January 06, 2020, 10:42:43 AM »
Hello! I have a question and new at scripting.

I'm trying to create a custom action and one line in particular keeps throwing me an error:

transform.position = Vector3.SmoothDamp (transform.position, targetPosition, ref velocity, smoothTime);

I saw another topic here from 2013 where someone else had the same issue and was told to replace the "tranform.position" with "Fsm.GameObject.transform" as its a mono behavior and doesn't work for FSM's. I ended up doing that:

Fsm.GameObject.transform = Vector3.SmoothDamp (Fsm.GameObject.transform, targetPosition, ref velocity, smoothTime);

But the MonoDevelop still throws me and error. I dont know what I am doing wrong with this and some assistance would be great. Its ONLY this line of code that throws the error and I spent the entire day just getting this far...

The entire code works in C# as a standalone script without any problems but I need this working as a programmable action.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Playmaker Custom Actions
« Reply #1 on: January 06, 2020, 10:47:26 AM »
Hi.
Can you show the script?

Wulfborn

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Playmaker Custom Actions
« Reply #2 on: January 06, 2020, 11:10:25 AM »
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{

   [ActionCategory(ActionCategory.Logic)]
   [Tooltip("test")]
   public class test : FsmStateAction
   {
      public Transform target;
      public float smoothTime = 0.3F;
      private Vector3 velocity = Vector3.zero;

      void Update()
      {
         Vector3 targetPosition = target.TransformPoint(new Vector3(0, 5, -10));

         Fsm.GameObject.transform = Vector3.SmoothDamp (Fsm.GameObject.transform, targetPosition, ref velocity, smoothTime);
      }

   }
}

I'm only having trouble with THIS line:

Fsm.GameObject.transform = Vector3.SmoothDamp (Fsm.GameObject.transform, targetPosition, ref velocity, smoothTime);

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Playmaker Custom Actions
« Reply #3 on: January 06, 2020, 11:10:43 AM »
I can only guess, but I assume you need the Fsm.GameObject.transform.position

Wulfborn

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Playmaker Custom Actions
« Reply #4 on: January 06, 2020, 11:35:34 AM »
I can only guess, but I assume you need the Fsm.GameObject.transform.position

Im using it but it keeps throwing an error in monodevelop. Ive clipped a screenshot to this topic. If I can just get that one line working properly then ill be good.

Edit: I didnt see that you added position at the end. Let me run that to see what happens.

Wulfborn

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Playmaker Custom Actions
« Reply #5 on: January 06, 2020, 11:44:23 AM »
I can only guess, but I assume you need the Fsm.GameObject.transform.position

Im not getting the error anymore but now the code simply doesn't function (in the sense that it doesn't operate at all)

Would I have to do a similar thing with this line as well?

Vector3 targetPosition = target.TransformPoint(new Vector3(0, 5, -10));