Hi all,
First post and just want to say that I'm absolutely loving this add-on. I'm Design Director at my company and next year I'm going to try to roll it out to my guys to use for prototyping.
Anyway, here's an action I just had to add for my own project. It will create a random point on a fictional sphere's surface which can be stored either as a Vector3 or as XYZ floats.
using UnityEngine;
using System.Collections;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Vector3)]
[Tooltip("Get Random Vector3 from the surface of a radius 1 Sphere")]
public class GetRandomPointOnSphere : FsmStateAction
{
[UIHint(UIHint.Variable)]
public FsmVector3 vector;
[UIHint(UIHint.Variable)]
public FsmFloat x;
[UIHint(UIHint.Variable)]
public FsmFloat y;
[UIHint(UIHint.Variable)]
public FsmFloat z;
public bool everyFrame;
public override void Reset()
{
vector = null;
x = null;
y = null;
z = null;
everyFrame = false;
}
public override void OnEnter()
{
DoGetRandomPointOnSphere();
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
DoGetRandomPointOnSphere();
}
void DoGetRandomPointOnSphere()
{
Vector3 position;
position = Random.onUnitSphere;
vector.Value = position;
x.Value = position.x;
y.Value = position.y;
z.Value = position.z;
}
}
}
It's pretty basic code that simply calls Unity's Random.onUnitSphere. Unfortunately the sphere has to be of radius 1 but you can then do stuff with the floats as a second step.
Bye,