playMaker

Author Topic: Vector3toString  (Read 6603 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15552
  • Official Playmaker Support
Vector3toString
« on: December 15, 2011, 02:16:00 AM »
Hi,

 Following this thread
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)"


Code: [Select]

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



markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Vector3toString
« Reply #1 on: April 09, 2012, 06:00:13 PM »
Thanks for that, was able to clean up lots of debug GUI FSMs :)

HAIRGROW

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Vector3toString
« Reply #2 on: October 21, 2016, 07:19:25 PM »
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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15552
  • Official Playmaker Support
Re: Vector3toString
« Reply #3 on: October 24, 2016, 10:17:09 AM »
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