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

Pages: [1] 2 3 ... 12
1
Playmaker Help / How to call PlayMaker Actions from script?
« on: April 10, 2013, 11:40:18 AM »
Is there a way to call a PlayMaker Action from a script? If yes, can someone post a code snippet?

I'm specifically trying to figure out how to obtain multiple return values from one action. For example, Raycast From Screen, which can return a Bool and a GameObject.

2
Share New Actions / Re: Rotorz Tile System Actions
« on: March 19, 2013, 06:05:11 PM »
I can vouch that Rotorz is AWESOME. If you're making a 2D or 3D tile-based game, or even a 2D game with layers of backgrounds, it's hard to beat this tool.

Check out the screenshot of what I've been able to make with it. The screenshot is a little low quality. In the game, the art looks flawless. I have two layers here: (a) background - seamless, you would never think it was tiled, (b) foreground - bricks, (c) animated water - will require a little extra coding, (d) objects with different shaped box colliders.

I'm currently using the Rotorz Playmaker actions to build and destroy terrain during gameplay, determine where my creatures can & can't go without having to rely on the physic engine, and a few other things.

Oh yeah... only THREE draw calls!!!
 

3
Official Action Updates / Re: NGUI Integration (WIP)
« on: March 06, 2013, 01:03:23 PM »
See my attachment. Yes, if this is what you are trying to do.

4
Share New Actions / Get File Name By Loop
« on: February 12, 2013, 10:03:44 PM »
This script returns the names of all files in a Resource Folder. You need to set this script up as a loop to extract each file name. I've attached a sample. Fields are:

  • Folder Name: enter the path where files are located inside the Resources directory. Leave this field empty to get all files in the Resource folder. Example usage: Creatures/Monsters/Ghosts
  • File Name: returns name of the next file in the directory.
  • Loop Event: A file was found. Do something and return to the loop.
  • No Hit Event: No files were found in directory. Exit loop early.
  • Finished Event: The Loop Event has been called for all files in the loop. Exit the loop.

This script is based on Jean's Get Next Ray Cast All Hit script.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Files")]
[Tooltip("Get the name of a file, using its index, in a specified resource folder.")]
public class GetFileNameByLoop : FsmStateAction
{
[Tooltip("The name of the folder where the file is located. If no folder name is entered, all Resource files are returned.")]
public FsmString folderName;

[Tooltip("The name of the file.")]
[UIHint(UIHint.Variable)]
public FsmString fileName;

[ActionSection("Hit")]

[Tooltip("Event to send to get the next child.")]
public FsmEvent loopEvent;

[Tooltip("Event to send if there is no hit at all")]
public FsmEvent noHitEvent;

[Tooltip("Event to send when there are no more hits to loop.")]
public FsmEvent finishedEvent;


public override void Reset()
{
folderName = null;
fileName = null;

loopEvent = null;
finishedEvent = null;
noHitEvent = null;
}

// cache the hits
private Object[] hits;

// increment a hit index as we loop through the hits
private int nextHitIndex;

public override void OnEnter()
{
if (nextHitIndex==0)
{
DoGetFileAll();
}

// no items found
if (hits.Length==0)
{
nextHitIndex = 0;
Fsm.Event(noHitEvent);
Fsm.Event(finishedEvent);
Finish();
return;
}

// final item
if (nextHitIndex>=hits.Length)
{
nextHitIndex = 0;
Fsm.Event(finishedEvent);
Finish();
return;
}

Debug.Log("getting index"+nextHitIndex );
fileName.Value = hits[nextHitIndex].name;

nextHitIndex++;

Fsm.Event(loopEvent);

Finish();
}


void DoGetFileAll()
{
hits = Resources.LoadAll(folderName.Value);
}

}
}

5
Share New Actions / Get File Name By Index
« on: February 12, 2013, 09:55:19 PM »
This script returns the name of a file at a specific index in a Resource Folder. Fields are:

  • Folder Name: enter the path where files are located inside the Resources directory. Leave this field empty to get all files in the Resource folder. Example usage: Creatures/Monsters/Ghosts
  • File Index: Index (position) of the file in the folder. Starts at 0.
  • File Name: returns the number of the file at the specified index.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Files")]
[Tooltip("Get the name of a file, using its index, in a specified resource folder.")]
public class GetFileNameByIndex : FsmStateAction
{
[Tooltip("The name of the folder where the file is located. If no folder name is entered, all Resource files are returned.")]
public FsmString folderName;

[Tooltip("The index of the file inside the folder. Index starts at 0.")]
public FsmInt fileIndex;

[Tooltip("The name of the file.")]
[UIHint(UIHint.Variable)]
public FsmString fileName;


public override void Reset()
{
folderName = null;
fileIndex = 0;
fileName = null;

}

public override void OnEnter()
{
DoGetFileName();
Finish();
}


void DoGetFileName()
{
Object[] resourceDir = Resources.LoadAll(folderName.Value);
fileName.Value = resourceDir[fileIndex.Value].name;
}

}
}

6
Share New Actions / Get File Count
« on: February 12, 2013, 09:49:53 PM »
This script returns the number of files in a Resource Folder. Fields are:

  • Folder Name: enter the path where files are located inside the Resources directory. Leave this field empty to get all files in the Resource folder. Example usage: Folder 1/Subfolder 1
  • File Count: returns the number of files in the specified directory.

Resources
-file 1
-file 2
-Folder 1
--file 1
--file 2
--Subfolder 1
---file 1

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Files")]
[Tooltip("Get the number of files in a resource directory.")]
public class GetFileCount : FsmStateAction
{

[Tooltip("The name of the folder.")]
public FsmString folderName;

[Tooltip("The number of files in the folder")]
[UIHint(UIHint.Variable)]
public FsmInt fileCount;


public override void Reset()
{
folderName = null;
fileCount = 0;
}

public override void OnEnter()
{
DoGetFileCount();

Finish();
}


void DoGetFileCount()
{
Object[] resourceDir = Resources.LoadAll(folderName.Value);
fileCount.Value = resourceDir.Length;
}

}
}

7
Share New Actions / Re: GetNextRaycastAllHit
« on: February 12, 2013, 08:06:11 PM »
Sorry, this is a little late. I've attached my FSM setup.

8
Feature Requests / Color-code input and output fields
« on: February 12, 2013, 07:16:28 PM »
One part of PlayMaker that gets confusing to me is knowing when a field is for input or output. It would be nice if there was a way for the person who is scripting an action to color-code certain text so that users will know which fields generate a result, and which fields are the result.

I know that some people might want to turn this feature on or off, so maybe if there was an option to to turn color-coding on or off?

For example, the following action is straight forward, but only because the author followed strict naming conventions:

FSM State Test (current)
-Game Object
-Fsm Name
-State Name
-True Event
-False Event
-Store Result

FSM State Test (alternative. red=input, blue=output)
-Game Object
-State Name
-State Name
-True Event
-False Event
-Result

9
Share New Actions / Re: GetNextRaycastAllHit
« on: January 24, 2013, 12:13:43 PM »
My workaround above didn't work, so I found another solution.

Here is what I'm doing:
The player can pick up creatures. If there are three creatures in one spot, only one creature needs to be picked up. It is possible that there may be plants in the way. Plants should be ignored.

Here is what happened:
(1) I used fingergestures as my start/idle state.
(2) When a click is found, the FSM jumps to the next state, which contains GetNextRaycastAllHit.
(3) GetNextRaycastAllHit gets a list of all game objects under the mouse (creatures, plants).
(4) A loop checks to see if the first object is a creature or plant. If it's a creature, the loop should break. If it's a plant, the loop should continue until a creature is found or all objects have been checked.
(5) If the first object is a creature, the loop breaks, and I can move the creature around.
(6) The FSM goes back to the start/idle state (directly linked to state that contains GetNextRaycastAllHit).
(7) Click on another creature. Data for the previous creature still in memory.

Hopefully this helps? It sounds like it's important not to have a direct link between the idle and raycast states?

10
Share New Actions / Re: Ray cast from screen space
« on: January 23, 2013, 05:56:05 PM »
Thank you very much! I needed this today.

11
Share New Actions / Re: GetNextRaycastAllHit
« on: January 23, 2013, 05:53:59 PM »
I wanted to add one small thing for anyone else who uses this. If you exit out of the loop early, the loop counter inside the action doesn't reset (by design), and if you use the loop again, the order of your objects will still have the counter from the first loop. To fix, I added a FsmBool called resetIndex to my code. I call GetNextRaycastAllHit in a separate state to reset this number before I call GetNextRaycastAllHit to get the raycast. Love this action, btw!

12
Feature Requests / Re: A few UI requests
« on: January 18, 2013, 12:56:25 PM »
Maybe this would work? More or less, highlighting is the same, but body is updated?

13
Feature Requests / Re: A few UI requests
« on: January 16, 2013, 08:37:35 PM »
I would LOVE to see color coding too. +1 on that! :)

14
Feature Requests / Re: Adding Array/Hashtable Natively
« on: January 16, 2013, 08:31:36 PM »
I also would like to see arrays available as a native component. ArrayMaker is great, but it would be so much easier if I could pass an array of gameobjects between actions the way I pass a single gameobject between actions.

I guess to me, when I think of GameObject[] and GameObject, I want to see them treated in a parallel way.

I don't edit any arrays by hand, so just being able to pass them around quickly w/o looking at debug data would be a nice beginning.

I've heard that Unity V4 makes it easier to customize the editor? I haven't updated from 3.5 yet, so I've not actually seen what has changed.


15
Share New Actions / Re: GetNextRaycastAllHit
« on: January 16, 2013, 05:05:58 PM »
Thank you, Jean. It turns out I needed this today. Saved me lots of work.

Pages: [1] 2 3 ... 12