PlayMaker Help & Tips > PlayMaker Help
Get an public Int to a Global FSM variable
(1/1)
Unbrick:
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: ---
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;
}
}
--- End code ---
So how do i get the _money to a Global FSM variable?
thanks in advance!
jeanfabre:
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
Navigation
[0] Message Index
Go to full version