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

Pages: [1] 2
Playmaker Bug Reporting / Re: state stop on first send event action
« on: April 07, 2018, 06:59:07 PM »
A quick guess is that on your GO goupille it is not on the correct state to accept the UNLOCK send event.
ie. If it is on the first state and that state does not have the UNLOCK event on it then this send event won't fire.
Second guess is that your FSM Name does not match correctly.

Playmaker Help / Re: Can't set non-string FSM variable?
« on: March 27, 2018, 01:10:51 PM »
For the bool:
Set Value:
-> with checkmark =  Set bool to True
-> no checkmark = Set bool to False

In short if you want the bool to set to false then leave the Set Value checkbox blank.

Action Requests / Re: Limit Look at Rotation
« on: March 15, 2018, 08:35:45 AM »
There are Look At and Smooth Look At actions.
To prevent it from rotating into a wall or object I use a float compare. When x/y > or < the area of rotation limit, we move to a second state that stops the turret/camera following the player.
Simple Setup:
1st State: (make sure every frame is selected on all)
Get property on turret x/y rotation - store in float value "rotation"
Float compare - "rotation" > 90 -> go to 2nd state -  this is your upper limit of rotation
Float compare - "rotation" < 0 -> go to 2nd state - this is your lower limit of rotation
Look at or Smooth Look At -> Player Object

2nd state:
 To get it to re-activate, should the player re-enter the area, here are a couple of options:

1. Have an empty game object inside your turret that continues to look at the player. This object will rotate without affecting your actual turret. Track its x/y rotation and do a float compare. When the values are within range then go back to your tracking state.

2. Have 2 colliders that are being checked for onTrigger. One at the top range and one at the bottom range and when the player enters go back to your tracking state.

Hope this helps.

Playmaker Help / Re: easy touch management across iOS / Android
« on: March 04, 2018, 07:48:49 AM »
The easiest way that I have found to be cross platform friendly is to use Unity's default UI button and send a PlayMakerFSM Event. This method will register both mouse or touch events.

Lets call it "My Button"
-> Add a FSM -> In the first state add a transition called "click" -> then add a second state that holds whatever actions you want done on click.

In the Button UI -> Button Script -> add an OnClick() event (hit the plus sign in the box) -> Runtime Only -> Drag in your "My Button" -> in the drop down select PlayMaker FSM -> Send Event(string) -> then type in "click" in the box underneath.

Playmaker Help / Re: Creating a .txt file? [SOLVED]
« on: February 09, 2018, 02:13:45 PM »
After much testing I noticed that there was a long delay between when the file was created until it would actually be available. So i modified the script to remove this issue.

Here is the complete script including a check to see if the new file is created.

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved.
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/

using UnityEngine;
using System.IO;
using UnityEditor; //<- added to make the AssetDatabase available.

namespace HutongGames.PlayMaker.Actions
[Tooltip("Write string to a File")]
public class WriteToFile : FsmStateAction
[Tooltip("Set the file path, for example : Assets/myfile.txt")]
public FsmString filePath;

        [Tooltip("The text")]
public FsmString text;

        public FsmEvent successEvent;
        public FsmEvent failureEvent;

        public override void Reset()
filePath = null;
text = null;


public override void OnEnter()
            if (File.Exists(filePath.Value))
                // Create an instance of StreamWriter to write text to a file.
                StreamWriter sw = new StreamWriter(filePath.Value, true);
                //Stream Writer will create the file automatically
                StreamWriter sw = new StreamWriter(filePath.Value, true);

                //re-import file and reference in editor

                //Check to see if file was created successfully
                if (File.Exists(filePath.Value))
                    Debug.Log("New File Made");
                    Debug.Log("Error: File not created");

Playmaker Help / Re: Activate gameobject based on a string name variable?
« on: February 07, 2018, 10:32:24 AM »
The Action Find Game Object will not return a result if the Parent object is deactivated.
One way to handle this is to create and empty game object that is always active and then put the items you want to activate/deactivate as children of this object.
eg. Parent Empty "Items"
Children - "GameObj01", "GameObj02" etc.

Then your FSM will look like

Find Game Object:
Object Name -> "Items"
With Tag -> (your tag here)
Store as "Parent_Object"

Find Child:
Game Object -> Specify -> Parent_Object
Child Name -> "Gameobj01" (or from a custom combine string)
Store -> Child_object

Activate Game Object:
Game Object -> Specify Object -> Child_Object
Activate -> On or off

Playmaker Help / Re: Creating a .txt file?
« on: February 03, 2018, 11:10:28 AM »
The Write to File script does not allow for creating a file.
Edit the Writeto File script to the below in the OnEnter Function
Note: This is just specific for creating a .txt file if not found and is not universal
Code: [Select]
public override void OnEnter()
            if (System.IO.File.Exists(filePath.Value))
                // Create an instance of StreamWriter to write text to a file.
                StreamWriter sw = new StreamWriter(filePath.Value, true);
                //create a .txt file if file does not exist
                //Now add in your data
                StreamWriter sw = new StreamWriter(filePath.Value, true);

General Discussion / Re: Activating objects between scenes
« on: January 06, 2018, 11:27:11 AM »
Use a global variable in Playmaker.
eg. Weapon 1 - Bool - True or false. (true unlocked)

You can reference global variables from any scene.

Playmaker Help / Re: High precision numbers with PlayMaker
« on: January 05, 2018, 08:06:02 AM »
Moving to a float would also get you a higher value allowable.
int = 2.1e+09 or 2,100,000,000
float= 3.4e+38 or 340,000,000,000,000,000,000,000,000,000,000,000,000

Converting float to string with a format 0 will remove the decimal places from showing. You can also format the string to allow the number to more human readable.

eg. 3 Billion -> 300 billion -> 3 trillion etc. instead of 3,000,000,000 -> 300,000,000,000 -> 3,000,000,000,000

If you are tracking scores above a trillion I, personally, wouldn't be too concerned that float may not give the precision you need as you are getting into massive numbers that start to lose meaning. Not a lot of people even know what comes after a Trillion  :)


Playmaker Help / Re: Changing backgrounds
« on: December 23, 2017, 06:10:59 AM »
Simplest way I found to change sprites at runtime is make a c# script and use the Playmaker Call Method to access when needed. You will need to make a Resources Folder and then a sub-folder to hold your sprites. In the example we called our sub-folder test.

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

public class SpriteTest : MonoBehaviour {
    //this is the folder in the first level of your Resources Folder
    private string spriteFolder = "test"; //<--Change this string to match folder name

    //The number in the array where the sprite is 0,1,2 etc.
    public int spriteVersion;

    //to get the sprite render component
    private SpriteRenderer spriteR;

    //to dump the sprites into an array from the folder listed above. Note that the sprites get added in order that they are in the folder. First sprite is 0, second is 1, etc.
    private Sprite[] sprites;

// Use this for initialization
void Start () {
        //Get the renderer of the sprite that this script is on.
        spriteR = this.GetComponent<SpriteRenderer>();

        //load the sprites from the Resources Folder for the folder you specified above
        sprites = Resources.LoadAll<Sprite>(spriteFolder);

    //call this function to update your sprite. use 0,1,2 etc to define which sprite you want to pull from the array.
    public void ChangeBackground(int background)
        spriteR.sprite = sprites[background];

Playmaker Help / Re: Install playMaker manually for every project?
« on: December 20, 2017, 12:17:29 PM »
When you create a new project in the Unity window, beside the 2/3D selection there is an add asset package button. You can select the packages to install at that time.


You have your value set as INT. This has the largest value allowable of 2147483647.
Changing this to a float will allow 3.40E+38 = 34 with 37 zeros behind it.
Doubles (which are not natively supported in Playmaker or PlayerPrefs) will get you 1.7E+308 = 17 with 307 zeros behind it.

It is possible to use Doubles with Playmaker. You will need to use a script to store the Double value and then convert to string to save, load and display.

You need to save the string value into PlayerPrefs and then convert it back into a double.

quick example: (just to give an outline)

Code: [Select]
//set up variables
public double scoreCounter;
public string scoreDisplay;

//get double to string value every frame
void Update()
//use the scoreDisplay to show value in game - use get property to dump into FSM
scoreDisplay = DoubleToString(scoreCounter);

//Functions for converting Double to string or string to double - C format used for currency display
    private static string DoubleToString(double doubleValue)
        return doubleValue.ToString("C");

    private static double StringToDouble(string stringValue)
        if (string.IsNullOrEmpty(stringValue))
            return 0d;

        return double.Parse(stringValue);

EDIT: Buy EasySave 2 from the asset store. This way you can keep the string in Playmaker Globals to save and load easily.
EasySave method:
FSM to save all global variables on exit or pause
FSM to load global variables then a call method to pass the StringToDouble function.
So much easier and secure than playerprefs. (Personal Opinion)

Playmaker Bug Reporting / Re: Compilation error
« on: December 08, 2017, 10:38:14 AM »
I know this one is a bit old, but it just happened to us.

I updated to Unity 2017.2.0F3.
Opened an existing small project from 5.6
Tried to build in VS 2017 - errors with Playmaker
Noticed that the namespace for Hutong was not referencing anymore/properly in VS 2017.

In the VS 2017 solution explorer window on right hand side, double click on your project name (not the ones with the .editor etc) -> double click references -> look for Playmaker.
In my case I had a yellow triangle in the icon. Once I clicked on the Playmaker reference once it seemed to resolve itself.

Not very technical, but I have had this work on 3 different projects now. 

Playmaker Tutorials / Re: Playmaker Array - Truncate / Number Formatting
« on: October 12, 2017, 07:38:45 AM »
Thanks for all the help djaydino. Great support from everyone here is the reason why I try to give back to this group.

Playmaker Tutorials / Re: Playmaker Array - Truncate / Number Formatting
« on: October 12, 2017, 05:04:11 AM »
Link fixed now (I hope).
just in case

Pages: [1] 2