Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on December 15, 2011, 02:16:00 AM
-
Hi,
Following this thread
http://hutonggames.com/playmakerforum/index.php?topic=774.0 (http://hutonggames.com/playmakerforum/index.php?topic=774.0)
Here is a simple action to save a vector3 into a string:
"Vector(-0.05288386,0.8564703,-0.5134802)"
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Vector3)]
[Tooltip("Builds a String from a vector3")]
public class Vector3toString : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.FsmVector3)]
public FsmVector3 vector3;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString storeResult;
public bool everyFrame;
public override void Reset()
{
vector3 = null;
storeResult = null;
everyFrame = false;
}
public override void OnEnter()
{
DoToString();
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
DoToString();
}
void DoToString()
{
storeResult.Value = "Vector("+vector3.Value.x+","+vector3.Value.y+","+vector3.Value.z+")";
}
}
}
Bye,
Jean
-
Thanks for that, was able to clean up lots of debug GUI FSMs :)
-
Hi Jean,
And thank you so much for providing this action. I was curious how the Float Conversion works? I see that it's pre-populated with the letter "G". I don't know what that means exactly. I tried a few other letters to see what would happen but the only one that seemed to do anything was "F". I noticed that it converted each axis value to display no more than 2 decimals places. Are there any other conversion methods or formats? Thanks in advance.
-
Hi,
yes: read this and you'll get a good overview:
https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx
Bye,
Jean