Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Wulfborn 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.
-
Hi.
Can you show the script?
-
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);
-
I can only guess, but I assume you need the Fsm.GameObject.transform.position
-
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.
-
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));