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 - Krileon

Pages: [1] 2
1
General Discussion / Will we ever see proper array support?
« on: August 10, 2014, 12:01:26 PM »
Is there an array variable type planned? Will we ever be able to use arrays or simple lists without having to use ArrayMaker and its proxy script? I'd really like to see internal support for arrays, which would bring significantly more usability.

2
PlayMaker Help / OnPostRender
« on: July 13, 2014, 09:11:12 AM »
I'm trying to attach an FSM to the main camera that has OnPostRender within it and some variables are set from PM. However, OnPostRender doesn't seam to work at all when inside of the action. Any suggests on getting this to work in an FSM? The below is my current code.

Code: [Select]
using UnityEngine;
using Rotorz.Tile;

namespace HutongGames.PlayMaker.Actions {
public class RTSysPreviewContext : MonoBehaviour, IBrushContext {
public TileSystem TileSystem;
public int Row;
public int Column;
public Brush Brush;

TileSystem IBrushContext.TileSystem {
get { return TileSystem; }
}

int IBrushContext.Row {
get { return Row; }
}
int IBrushContext.Column {
get { return Column; }
}

Brush IBrushContext.Brush {
get { return Brush; }
}
}

[ActionCategory("Rotorz Tile System")]
public class RTSysPreview : FsmStateAction {
[ObjectType(typeof(TileSystem)), Tooltip("The Tile System component. Not needed if System GameObject is used.")]
public FsmObject systemObject;
[Tooltip("Game Object reference to Tile System. Not needed if System Object is used.")]
public FsmOwnerDefault systemGameObject;
[RequiredField, ObjectType(typeof(Brush))]
public FsmObject brushObject;
[RequiredField]
public FsmInt row;
[RequiredField]
public FsmInt column;
[RequiredField]
public FsmMaterial material;

private Object previousOSystem;
private GameObject previousGoSystem;
private TileSystem system;
private Brush brush;

public override void Reset() {
systemObject = new FsmObject { UseVariable = true };
systemGameObject = null;
brushObject = new FsmObject { UseVariable = true };
row = new FsmInt { UseVariable = true };
column = new FsmInt { UseVariable = true };
material = new FsmMaterial { UseVariable = true };
}

public override void OnUpdate() {
if ( systemObject.Value == null ) {
var goSystem = Fsm.GetOwnerDefaultTarget( systemGameObject );

if ( goSystem == null ) {
return;
}

if ( goSystem != previousGoSystem ) {
system = goSystem.GetComponent<TileSystem>();
previousGoSystem = goSystem;
}
} else {
if ( systemObject.Value != previousOSystem ) {
system = systemObject.Value as TileSystem;
previousOSystem = systemObject.Value;
}
}

if ( system == null ) {
return;
}

if ( brushObject.Value == null ) {
return;
}

brush = brushObject.Value as Brush;
}

void OnPostRender() {
if ( brush != null ) {
ImmediatePreviewUtility.Matrix = system.transform.localToWorldMatrix;

RTSysPreviewContext context = new RTSysPreviewContext();

context.Brush = brush;
context.Column = column.Value;
context.Row = row.Value;
context.TileSystem = system;

TileData tile = system.GetTile( row.Value, column.Value );

brush.OnDrawImmediatePreview( context, tile, material.Value, brush );
}
}
}
}

3
PlayMaker Help / Template action usages not being found
« on: May 18, 2014, 01:34:27 PM »
If you use an Action in a template then the action browser does not show the usages from those templates. Even if you're editing the template and in the action browser it still won't show the actions as being used in that template. Is there any way to get it to parse through templates and check for action usage? Is this planned behavior? Can it be implemented if it's not?

4
If your action has an FsmVar and you add/remove/edit another variable (with no relation to the FsmVar) it causes the FsmVar values to reset. This is a HUGE problem if you need to fix a bug or add another variable that has nothing to do with the FsmVar as it causes the FsmVar to completely lose its values (resets to Float: None). Example as follows.

FROM:
Code: [Select]
[RequiredField, UIHint(UIHint.Variable)]
public FsmVar variable;
[RequiredField]
public FsmString path;
TO:
Code: [Select]
[RequiredField, UIHint(UIHint.Variable)]
public FsmVar variable;
[RequiredField]
public FsmString path;
public FsmBool encrypt;

Adding the "encrypt" variable that has nothing to do with "variable", which is an FsmVar still causes any usages of the action to lose its values for "variable". This causes a nightmare of issues as you have to scan through all your FSMs, find the usages, and manually fix them.

5
PlayMaker Help / Template debugging out of sync
« on: May 17, 2014, 04:49:59 PM »
I'm getting slammed with dozens of "Missing Action" errors from my templates. I created a new action to do what I'm wanting, setup the new action, removed the old action from the template, then deleted the action from my project. Yet it's flipping out that an action is missing in my template. How do I shut this thing up? My templates are working fine so I don't understand why it's doing this.

6
Share New Actions / String Regex Match
« on: April 13, 2014, 12:25:36 PM »
Yet another string regex action. This one, similar to String Regex Is Match, can do a true/false event based off the match, but it also stores the result of the match to another string variable instead of storing true/false to boolean.

[edit] You can now get it directly from the Ecosystem

StringRegexMatch

Code: [Select]
using UnityEngine;
using System.Text.RegularExpressions;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.String)]
public class StringRegexMatch : FsmStateAction {
[RequiredField, UIHint(UIHint.Variable)]
public FsmString stringVariable;
public FsmString regex;
public RegexOptions[] options;
[UIHint(UIHint.Variable)]
public FsmString storeMatch;
[UIHint(UIHint.Variable)]
public FsmEvent trueEvent;
[UIHint(UIHint.Variable)]
public FsmEvent falseEvent;
public bool everyFrame;

public override void Reset() {
stringVariable = null;
regex = new FsmString { Value = "" };
options = new RegexOptions[0];
storeMatch = null;
trueEvent = null;
falseEvent = null;
everyFrame = false;
}

public override void OnEnter() {
DoAction();

if ( ! everyFrame ) {
Finish();
}
}

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

void DoAction() {
Match match = null;

if ( options.Length > 0 ) {
RegexOptions optionsBit = 0;

foreach ( RegexOptions option in options ) {
optionsBit |= option;
}

match = Regex.Match( stringVariable.Value, regex.Value, optionsBit );
} else {
match = Regex.Match( stringVariable.Value, regex.Value );
}

storeMatch.Value = match.Value;

if ( match.Success ) {
if ( trueEvent != null ) {
Fsm.Event( trueEvent );
}
} else {
if ( falseEvent != null ) {
Fsm.Event( falseEvent );
}
}
}
}
}

You can find my other String Regex actions as follows.

String Regex Is Match:
http://hutonggames.com/playmakerforum/index.php?topic=7005.0

String Regex Replace:
http://hutonggames.com/playmakerforum/index.php?topic=7004.0

7
Share New Actions / String Regex Is Match
« on: April 13, 2014, 12:14:31 PM »
Just sharing another regex action. This one fires a true/false event based off the regex match or just stores the result of the match (you pick).

[Edit] Youc an get it directly from the Ecosystem

StringRegexMatch

Code: [Select]
using UnityEngine;
using System.Text.RegularExpressions;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.String)]
public class StringRegexIsMatch : FsmStateAction {
[RequiredField, UIHint(UIHint.Variable)]
public FsmString stringVariable;
public FsmString regex;
public RegexOptions[] options;
[UIHint(UIHint.Variable)]
public FsmBool storeMatch;
[UIHint(UIHint.Variable)]
public FsmEvent trueEvent;
[UIHint(UIHint.Variable)]
public FsmEvent falseEvent;
public bool everyFrame;

public override void Reset() {
stringVariable = null;
regex = new FsmString { Value = "" };
options = new RegexOptions[0];
storeMatch = null;
trueEvent = null;
falseEvent = null;
everyFrame = false;
}

public override void OnEnter() {
DoAction();

if ( ! everyFrame ) {
Finish();
}
}

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

void DoAction() {
if ( options.Length > 0 ) {
RegexOptions optionsBit = 0;

foreach ( RegexOptions option in options ) {
optionsBit |= option;
}

storeMatch.Value = Regex.IsMatch( stringVariable.Value, regex.Value, optionsBit );
} else {
storeMatch.Value = Regex.IsMatch( stringVariable.Value, regex.Value );
}

if ( storeMatch.Value ) {
if ( trueEvent != null ) {
Fsm.Event( trueEvent );
}
} else {
if ( falseEvent != null ) {
Fsm.Event( falseEvent );
}
}
}
}
}

For my String Regex Replace action please see the below topic.

http://hutonggames.com/playmakerforum/index.php?topic=7004.0

8
Share New Actions / String Regex Replace
« on: April 13, 2014, 11:57:31 AM »
I wanted to use REGEX for my replacement usage so I created a String Regex Replace. Thought I'd go ahead and share it as it's a pretty generic and useful action.

[edit] It's now available directly on the Ecosystem

StringRegexReplace

Code: [Select]
using UnityEngine;
using System.Text.RegularExpressions;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.String)]
public class StringRegexReplace : FsmStateAction {
[RequiredField, UIHint(UIHint.Variable)]
public FsmString stringVariable;
public FsmString regex;
public FsmString with;
public RegexOptions[] options;
[RequiredField, UIHint(UIHint.Variable)]
public FsmString storeResult;
public bool everyFrame;

public override void Reset() {
stringVariable = null;
regex = new FsmString { Value = "" };
with = new FsmString { Value = "" };
options = new RegexOptions[0];
storeResult = null;
everyFrame = false;
}

public override void OnEnter() {
DoAction();

if ( ! everyFrame ) {
Finish();
}
}

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

void DoAction() {
if ( options.Length > 0 ) {
RegexOptions optionsBit = 0;

foreach ( RegexOptions option in options ) {
optionsBit |= option;
}

storeResult.Value = Regex.Replace( stringVariable.Value, regex.Value, with.Value, optionsBit );
} else {
storeResult.Value = Regex.Replace( stringVariable.Value, regex.Value, with.Value );
}
}
}
}

I'll probably be adding other regex actions as well such as Match. Anyway, hope others find as much use out of this as I have.

9
PlayMaker Help / Action name separate from class name
« on: April 12, 2014, 09:53:08 AM »
It's possibly to specify a category string name, but it's not possible from what I can tell to specify an action string name. It always uses the class name and the algorithm used to generate a spaced name from class isn't what I'd prefer. Is it possible for such a feature to be implemented? I'd really like to be able to supply my own string name instead of always using the class name.

For example the below is not very sightly.

Class: EZSave2SaveVariable
Name: EZ Save 2Save Variable
Wanted: EZSave2 Save Variable

I prefix all of my classes to avoid conflicts and make it easier to see at a glance what action belongs to what when it's in use. This works really well, but I've to be annoyingly creative with my class names so they don't look terrible as the action name.

10
PlayMaker Help / FsmProperty limitations, workaround?
« on: February 16, 2014, 09:01:39 AM »
FsmProperty only displays the properties that PM can store as FSM variables. My issue is I don't want to store it as an FSM variable. I have a playmaker action for my JSON.Net implementation that takes property and encodes it. All I want to do is send that property to the FSM. I don't actually want to store it as an FSM variable (I'll store the JSON string output by the FSM).

How can I have a property dropdown that shows all of a components properties regardless if PM can store them or not? Can I implement my own type like FsmProperty that'd handle this? If so can you provide an example? I decompiled the FsmProperty, but am unsure if copy/paste/modify into a new script will even work.

Edit: Ok, copy/paste/modify of FsmProperty doesn't work for sure. So I guess that's not an option unfortunately.

11
Share New Actions / Realtime Cubemaps
« on: December 31, 2013, 07:41:37 AM »
THIS WILL ONLY WORK IN UNITY PRO

Had to make that warning pretty clear. This is a Unity limitation so there is no workaround for this.

Ok, so I've been looking into realtime reflections and the best I could find at the moment is realtime cubemap generation. The alternative is a post processing affect that pulls from buffer, but that's above my current experience.

The below PlayMaker action will generate cubemaps at realtime for the target object and update the shader as needed. It has built in optimization to prevent performance from dieing. Basically what it does is on start will populate all 6 sides then every 5 frames it'll populate 1 face. This keeps performance from going to crap while still giving realtime reflections. You can customize a lot of the camera properties from the playmaker action as well as debug it (helps to make sure your positioning is correct).

The camera generated to pull the cubemaps is added as a child object of the target object so all position/rotation supplied is local. This lets the cubemap generation follow the object (cars, marbles, etc..).

The action can also be used as a fire and forget usage. Meaning it'll generate the 6 sides then destroy the camera and end the action. This is good for static objects that you're reusing throughout your level and need each with their own cubemap.

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.Camera)]
public class CameraRenderToCubemap : FsmStateAction {
[RequiredField]
public FsmOwnerDefault targetGameObject;
[ActionSection("Camera")]
public FsmVector3 position;
public FsmQuaternion rotation;
public FsmColor backgroundColor;
[RequiredField, HasFloatSlider(1,179)]
public FsmFloat fieldOfView;
[RequiredField]
public FsmFloat nearCipPlane;
[RequiredField]
public FsmFloat farClipPlane;
public FsmBool HDR;
[ActionSection("Culling")]
[UIHint(UIHint.Layer)]
public FsmInt[] cullingMask;
public FsmBool invertMask;
[ActionSection("Cubemap")]
[RequiredField]
public FsmInt cubemapSize;
[RequiredField]
public FsmString[] namedCubemaps;
[ActionSection("Realtime")]
public bool everyFrame;
public int frameDelay;
public bool oneFacePerFrame;
public bool debugCamera;

private GameObject target;
private GameObject camera;
private RenderTexture texture;
private int frames;
private int[] faces;
private int face;

public override void Reset() {
targetGameObject = null;
position = new FsmVector3 { UseVariable = true };
rotation = new FsmQuaternion { UseVariable = true };
backgroundColor = new FsmColor { UseVariable = true };
fieldOfView = new FsmFloat { Value = 60f };
nearCipPlane = new FsmFloat { Value = 0.01f };
farClipPlane = new FsmFloat { Value = 100f };
HDR = new FsmBool { Value = false };
namedCubemaps = new FsmString[1];
namedCubemaps[0] = new FsmString { Value = "_Cube" };
cubemapSize = new FsmInt { Value = 128 };
cullingMask = new FsmInt[0];
invertMask = false;
everyFrame = true;
frameDelay = 0;
oneFacePerFrame = true;
debugCamera = false;

faces = new int[6];
faces[0] = ( 1 << (int) CubemapFace.NegativeX ); // 2
faces[1] = ( 1 << (int) CubemapFace.NegativeY ); // 8
faces[2] = ( 1 << (int) CubemapFace.NegativeZ ); // 32
faces[3] = ( 1 << (int) CubemapFace.PositiveX ); // 1
faces[4] = ( 1 << (int) CubemapFace.PositiveY ); // 4
faces[5] = ( 1 << (int) CubemapFace.PositiveZ ); // 16

frames = 0;
face = 0;
}

public override void OnEnter() {
target = Fsm.GetOwnerDefaultTarget( targetGameObject );

if ( target == null ) {
return;
}

camera = new GameObject( "CubemapCamera", typeof( Camera ) );
camera.hideFlags = ( debugCamera ? HideFlags.DontSave : HideFlags.HideAndDontSave );
camera.transform.parent = target.transform;
camera.transform.localPosition = position.Value;
camera.transform.localRotation = rotation.Value;

camera.camera.backgroundColor = backgroundColor.Value;
camera.camera.cullingMask = ActionHelpers.LayerArrayToLayerMask( cullingMask, invertMask.Value );
camera.camera.fieldOfView = fieldOfView.Value;
camera.camera.nearClipPlane = Mathf.Min( 0.01f, nearCipPlane.Value );
camera.camera.farClipPlane = farClipPlane.Value;
camera.camera.hdr = HDR.Value;
camera.camera.enabled = false;

texture = new RenderTexture( cubemapSize.Value, cubemapSize.Value, 16 );
texture.isCubemap = true;
texture.hideFlags = HideFlags.HideAndDontSave;

if ( namedCubemaps.Length > 0 ) foreach ( FsmString namedCubemap in namedCubemaps ) {
target.renderer.material.SetTexture( namedCubemap.Value, texture );
}

camera.camera.RenderToCubemap( texture, 63 );

if ( ! everyFrame ) {
Object.Destroy( camera );
Finish();
}
}

public override void OnLateUpdate() {
if ( ( target == null ) || ( camera == null ) ) {
return;
}

if ( frameDelay > 0 ) {
if ( frames == frameDelay ) {
frames = 0;
} else {
frames++;
return;
}
}

if ( oneFacePerFrame ) {
camera.camera.RenderToCubemap( texture, faces[face] );

if ( face == 5 ) {
face = 0;
} else {
face++;
}
} else {
camera.camera.RenderToCubemap( texture, 63 );
}
}

public override void OnExit() {
if ( camera == null ) {
return;
}

Object.Destroy( camera );
}
}
}

Please understand I do not have time to provide support. I'm providing this as it was a nightmare for me to figure this out on my own and Unity documentation sucks. So hopefully this will reduce the pain and suffering for another.

12
If you namespace your actions (e.g. namespace HutongGames.PlayMaker.Actions.Anim) then use a class like "Play" and have another action that is also namespaced "namespace HutongGames.PlayMaker.Actions.AudioToolkit" which uses a class of "Play" it causes the below error when trying to use the Action Browser. It's using the class name as the key for a dictionary, but this doesn't seam to be the correct approach as it's not considering the namespace. The end result is I have to name my actions stupidly (e.g. AnimPlay, AudioToolkitPlay) for them to not conflict even though they already won't because they have a unique namespace. Can a new method be implemented to build the list to avoid this issue?

Code: [Select]
ArgumentException: An element with the same key already exists in the dictionary.
System.Collections.Generic.Dictionary`2[System.Type,UnityEngine.Object].Add (System.Type key, UnityEngine.Object value) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
HutongGames.PlayMakerEditor.FsmEditorUtility.BuildActionScriptLookup ()
HutongGames.PlayMakerEditor.FsmEditorUtility.BuildActionsList ()
HutongGames.PlayMakerEditor.ActionSelector.Initialize ()
HutongGames.PlayMakerEditor.BaseEditorWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

13
PlayMaker Help / Missing set for CollisionInfo or am I missing something?
« on: December 21, 2013, 06:38:45 PM »
CollisionInfo only has "get" so it's not possible to "set" the collision info so the get collision info action can be used. With raycasts for example you want to set RaycastHitInfo so the raycast info action can be used. I want to do the same for collisions, but CollisionInfo is missing "set". Is there a function to set this or can you add "set" for next release?

14
PlayMaker Help / Add FSM Template at Runtime? [SOLVED]
« on: December 18, 2013, 08:56:08 PM »
I've found the best way to do Debuffs/Buffs and things of the sort is to attach the script then have it remove it self when the debuff/buff has expired. For PlayMaker the best way to do this would be to add a template at runtime anytime you want to add the debuff/buff. Ideally when doing this it should also check to see if the template already exists and if it does optionally replace it or do nothing. This would be EXTREMELY handy.

Is something like this available? Is there API for even adding an FSM at runtime? If it's not available, but API is there to do it I'll g ahead and just make a new action for it.

Note I've tried other alternatives like having an FSM disabled then enabling it, sending an event, or flipping a variable and having it check every frame if the variable changed. All of these work, but none of them are ideal. Sure it works if you have a hand full of debuffs/buffs, but lets say you've dozens upon dozens it quickly begins to fail as an option to do either of those.

15
PlayMaker Help / OnParticleCollision available?
« on: August 11, 2013, 10:20:20 AM »
The last topic in regards to OnParticleCollision was in 2012. Has this been added into PlayMaker yet? I need my flamethrower trap and a few other traps to kill some units when the particle collides with them. Would be very helpful if we could utilize this event to detect if a particle has collided with something. Otherwise I suppose a proxy script to forward the event will work, but would be nice to have it built in. Any suggestions?

Pages: [1] 2