playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - speedything

Pages: [1]
1
PlayMaker Help / Set audio clip variable [SOLVED]
« on: January 23, 2012, 12:07:53 PM »
Hi guys,

I'm trying to use the "Set Audio Clip" action with a variable audio object but I can't find the variable. Reproduction steps are...

1. Create an FSM and add an object variable - "audioClip"
2. Select the "Set Audio Clip" action and assign a Game Object with an audio source component. I would expect to be able to assign the variable created in step 1 to the "Audio Clip" field, but it can't see it.

The same thing problem occurs with the "Audio Play" action.

Am I doing something wrong? Or is this a bug with the action?

Thanks,


2
Share New Actions / Get random point in transform
« on: January 06, 2012, 08:20:10 PM »
Following my theme of randomness, here's a new action. It allows you to find a random point within a transform, or at least it will for cubes and rectangles. Not so effective for circular objects...

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions

{
[ActionCategory(ActionCategory.Transform)]
[Tooltip("Gets a Random Position in a Transform")]
public class GetRandomPositionInTransform : FsmStateAction
{
[RequiredField]
public FsmOwnerDefault gameObject;
[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 Space space;
public bool everyFrame;

public override void Reset()
{
gameObject = null;
vector = null;
x = null;
y = null;
z = null;
space = Space.World;
everyFrame = false;
}

public override void OnEnter()
{
DoGetRandomPositionInTransform();

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
DoGetRandomPositionInTransform();
}

void DoGetRandomPositionInTransform()
{
GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null) return;

Vector3 position;

if (space == Space.World)
{

position = go.transform.position;
}

else
      {
         position = go.transform.localPosition;
}

Vector3 scale;

            if (space == Space.World)

            {
                scale = go.transform.lossyScale;
            }

            else

            {
                scale = go.transform.localScale;
            }

var halfX = scale.x/2f;
var halfY = scale.y/2f;
var halfZ = scale.z/2f;

var randomX = Random.Range(-halfX, halfX);
var randomY = Random.Range(-halfY, halfY);
var randomZ = Random.Range(-halfZ, halfZ);

            x.Value = position.x + randomX;
            y.Value = position.y + randomY;
            z.Value = position.z + randomZ;

Vector3 randomVector3;

randomVector3.x = x.Value;
randomVector3.y = y.Value;
randomVector3.z = z.Value;

vector.Value = randomVector3;

}
}
}

Personally I'm using this to give my AI people a variety of destinations within an area that I can simply bound by creating a rectangle object.

Bye,


3
Share New Actions / Get Random Point On Sphere
« on: December 16, 2011, 11:39:02 AM »
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.

Code: [Select]
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,


Pages: [1]