playMaker

Author Topic: Get an public Int to a Global FSM variable  (Read 1386 times)

Unbrick

  • Playmaker Newbie
  • *
  • Posts: 1
Get an public Int to a Global FSM variable
« on: February 13, 2014, 04:01:27 PM »
Hey guys,
i need a little help:

i just got a project which a friend of me coded and i just want to translate the GUI-part to playmaker. So i have to get the public int _money to an global FSM variable but i dont know how to do that.

here a litte piece of the code:
Code: [Select]

using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;


public class money : MonoBehaviour {

public int _money;

// Update is called once per frame
void Update () {
int t, h, z, e, m;

weapons sendMoney= gameObject.GetComponent<weapons>();
sendMoney.reciveMoney(_money);

t = _money/1000;

h = _money%1000;
h = h/100;

z = _money%1000;
z = z%100;
z = z/10;

e = _money%10;


}

public void getMoney(int amt){
_money += amt;
}

public void looseMoney(int amt){
_money -= amt;
}


}


So how do i get the _money to a Global FSM variable?

thanks in advance!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get an public Int to a Global FSM variable
« Reply #1 on: February 14, 2014, 12:00:54 AM »
Hi,

http://hutonggames.com/playmakerforum/index.php?topic=6317.msg30830#msg30830



warning: your script is really not optimized, so be careful to watch for performance issues here.

--  cache your weapons component ( only get it once basically)
-- only perform an operation when needed ( not in the update loop, but as a function you call from getMoney and loosemoney. There is no point ocmputing over and over the same values on update.
-- Same goes with the global variable, cache it once, and then use that reference.

bye,

 Jean