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.


Messages - Krileon

Pages: 1 2 [3] 4 5 ... 8
31
PlayMaker Help / Re: Add FSM Template at Runtime?
« on: December 26, 2013, 08:20:34 AM »
Ah, I was trying to use this.Owner. That works perfectly! Below is the final destroy fsm action, works perfectly.

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.StateMachine)]
public class DestroyFSM : FsmStateAction {

public override void OnEnter() {
if ( Fsm.Owner != null ) {
Object.Destroy( Fsm.Owner );
}

Finish();
}
}
}

32
Right now CollisionInfo set is private. I'll make it public in the next update...
Awesome, thanks! :)

Including my physics cast actions encase anyone is curious. Note I do not include tooltips or documentation links in any of my actions. They're all designed to mimic real API usage so just check Unity script reference.

Following included:
CapsuleCast
CheckCapsule
SphereCast
CheckSphere
OverlapSphere

Just a disclaimer: I do not have time to provide support. Please don't hammer me with questions, usages, etc.. I can't do it. I just don't have the time between my full time job and working on my own projects. If you run into an issue, you can post it here but I probably won't ever fix it unless it directly affects my project. All of the above are tested and I use OverlapSphere quite extensively. There's no license for any of these.. use however you like (can clean up with tooltips and include in next PM release if you want).

33
PlayMaker Help / Re: Add FSM Template at Runtime?
« on: December 25, 2013, 08:16:50 PM »
Very cool stuff Krileon!

In DestroyFSM you should be able to just use Object.Destroy(fsm.Owner);
That'd destroy the gameObject. I want to just destroy the FSM. The structure is Component.Fsm.etc, but in the action "this" and "Fsm" are both the ".Fsm" part of the structure. I can't find a way to go back by 1 and get the component object so it could be destroyed. Only solution I found thus far was to parse out all the owners FSM components, compare to the component to destroy, once matched destroy it. This works flawlessly, but I believe there has to be another way (in a normal script you'd just destroy "this").

Anyway, this is totally awesome. I have 2 scenarios already implemented in my game. 1 is a "Slow" template that can take a "Drag" variable and apply drag for a set time limit to one of my rigidbodies then restore to normal and remove it self. I have another that is a "Scare" template that causes a rigidbody to reverse its direction by sending a new event state to the controller FSM (another custom action, I wrote a rigidbody collisions action to mimic normal controller usage).

34
PlayMaker Help / Re: Add FSM Template at Runtime?
« on: December 25, 2013, 04:22:17 PM »
Ok, the below action will delete an FSMs self. I had to loop through the FSMs on the owner then compare to the current FSM to implement this though. Pretty silly to have to actually. The FSM should be updated with a variable that stores its component or at least a utility to more efficiently grab the component. Anyway the below works.

Code: [Select]
using UnityEngine;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.StateMachine)]
public class DestroyFSM : FsmStateAction {

public override void OnEnter() {
if ( Owner != null ) {
PlayMakerFSM[] fsms = Owner.GetComponents<PlayMakerFSM>();

if ( fsms.Length > 0 ) foreach ( PlayMakerFSM fsm in fsms ) {
if ( fsm.Fsm.CompareTo( Fsm ) == 0 ) {
Object.Destroy( fsm );
}
}
}

Finish();
}
}
}

I now no longer need to have a dozen objects checking every frame if they've changed variables or waiting for an event. I can now add them, with the needed variables, and remove them automatically. My "Slow" debuff is working fantastically. I don't see any performance loss from using this either.

35
PlayMaker Help / Re: Add FSM Template at Runtime?
« on: December 25, 2013, 02:27:16 PM »
Ok, the below action will add a FSM Template at runtime.

It'll also optionally check if the FSM Template should be unique or not. If it's Unique then it's a unique instance and won't bother checking if an instance of the same FSM Template already exists. If it's not unique then it'll check if the FSM name (if supplied) exists or the FSM template exists. If either of them do exist when it's not unique then it won't add the FSM template.

You can optionally set the FSM to be enabled or disabled on creation so you can optionally enable it later as needed.

Last but not least you can optionally send variables to the newly added template. This will initially disable the FSM, add the template, change the variables, then enable the FSM so it can properly start with the variables added.

Code: [Select]
using System.Collections.Generic;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions {
[ActionCategory(ActionCategory.StateMachine)]
public class AddFsmTemplate : FsmStateAction {
[RequiredField]
public FsmOwnerDefault gameObject;
[RequiredField]
public FsmTemplate template;
public FsmString name;
public FsmBool active;
public FsmBool unique;
[CompoundArray("Variables", "Name", "Variable")]
[RequiredField]
public FsmString[] variableNames;
[RequiredField]
public FsmVar[] variables;

private GameObject previousGo;
private List<PlayMakerFSM> fsms;

public override void Reset() {
gameObject = null;
template = null;
name = new FsmString { UseVariable = true };
active = new FsmBool { Value = true };
unique = new FsmBool { Value = false };
variableNames = new FsmString[0];
variables = new FsmVar[0];
}

public override void OnEnter() {
var go = Fsm.GetOwnerDefaultTarget( gameObject );

if ( go == null ) {
return;
}

bool exists = false;

if ( ! unique.Value ) {
if ( go != previousGo ) {
fsms = new List<PlayMakerFSM>();

fsms.AddRange( go.GetComponents<PlayMakerFSM>() );

previousGo = go;
}

if ( fsms.Count > 0 ) foreach ( PlayMakerFSM fsm in fsms ) {
if ( ( ( name.Value != "" ) && ( fsm.FsmName == name.Value ) ) || ( ( fsm.FsmTemplate != null ) && ( fsm.FsmTemplate.name == template.name ) ) ) {
exists = true;
}
}
}

if ( ! exists ) {
PlayMakerFSM newFsm = go.AddComponent<PlayMakerFSM>();

if ( name.Value != "" ) {
newFsm.FsmName = name.Value;
}

if ( ( ! active.Value ) || ( variableNames.Length > 0 ) ) {
newFsm.enabled = false;
}

newFsm.SetFsmTemplate( template );

if ( variableNames.Length > 0 ) {
if ( variableNames.Length > 0 ) for ( int i = 0; i < variableNames.Length; i++ ) {
if ( ! variableNames[i].IsNone ) {
NamedVariable target = newFsm.Fsm.Variables.GetVariable( variableNames[i].Value );

if ( target != null ) {
variables[i].ApplyValueTo( target );
}
}
}

if ( active.Value && ( ! newFsm.enabled ) ) {
newFsm.enabled = true;
}
}

if ( ! unique.Value ) {
fsms.Add( newFsm );
}
}

Finish();
}
}
}

Now all that's left is a "DestroyFSM" action to completely get rid of the FSM component. I have yet to figure this one out yet, but once I do this can be used very effectively for spell debuffs, temporary affects like drag on a rigidbody to simulate "slowing", and much much more.

Regarding performance using the above I saw very little loss, if any at all, so it seams perfectly safe to use as needed.

36
PlayMaker Help / Re: Add FSM Template at Runtime?
« on: December 25, 2013, 12:36:09 PM »
Ok, I was able to add the template pretty easily. Performance seams ok thus far. Now I need to destroy the template (I'll have this done from the FSM, it needs to destroy it self). This allows for a debuff to run for a specific amount of time and get rid of it self. This is critical usage as adding a ton of disabled FSMs per debuff per object would be insane for example.

37
When a collision occurs then the data is set automatically.
Only for specific usages and situations. I wrote SphereCast, CapsuleCast, SphereCheck, CapsuleCheck, and OverlapSphere actions. OverlapSphere returns an array of colliders. I want to set the FSM collider to the first collider that OverlapSphere returns. To do that CollisionInfo needs a set the same way you can do it with RaycastHitInfo.

38
Any feedback regarding this? Would this be counted as a bug or intended?

39
How do I submit a bug report? O.o

Edit: Nevermind. I feel stupid. It's stickied, lol.

40
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)

41
PlayMaker Help / Missing set for CollisionInfo or am I missing something?
« on: December 21, 2013, 08: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?

42
PlayMaker Help / Re: Add FSM Template at Runtime?
« on: December 19, 2013, 12:51:32 PM »
Awesome, I'll make a playmaker action that does that and see how it goes.

43
PlayMaker Help / Add FSM Template at Runtime? [SOLVED]
« on: December 18, 2013, 10: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.

44
PlayMaker Help / Re: OnParticleCollision available?
« on: August 13, 2013, 08:49:25 PM »
Yeah, you would need a small proxy script to send an event to an FSM.
Ok, no problem. Thanks for confirming. :)

I'll try to get this added to the next update so it's built in...
Awesome, thank you! As always Alex you're the best!

45
PlayMaker Help / Re: OnParticleCollision available?
« on: August 13, 2013, 11:27:15 AM »
Anyone have any idea? Am not seeing anything for this in dotPeek. So am guessing this needs to be done with a proxy script to send the event to an FSM? will the collision enter/exit work?

Pages: 1 2 [3] 4 5 ... 8