Calling a Method using SendEvent
Posted: Sat Oct 08, 2016 9:26 am
Hello, I'm having an issue with the SendEvent sequence. My coding level is very, very basic at the moment, so I'm sure this is a matter of me not understanding something and possibly using the wrong sequence entirely, ahahaha.
I have an empty gameobject called MoneyManager. I attached a C# script to it called money. Inside that script I have a really simple method called takemymoney.
When I call this method by clicking a UI button, it works exactly as expected. It takes whatever value I put in and subtracts it from my int currentMoney with every click.
What I hoped to accomplish is upon saying you'll buy something in the dialogue system (clicking 'yes' as a response when prompted) the method will run, subtracting an amount from my int currentMoney.
So, I used SendMessage(takemymoney, 5, MoneyManager) in the sequencer on the node after you agree to buy the item. This gives me the following error:
Dialogue System: Lua code 'return SendMessage(takemymoney, 5, MoneyManager)' threw exception 'Invoke function call on non function value.'
UnityEngine.Debug:LogError(Object)
Any suggestions on how to accomplish what I'm attempting?
I have an empty gameobject called MoneyManager. I attached a C# script to it called money. Inside that script I have a really simple method called takemymoney.
Code: Select all
public void takemymoney(int takemoney)
{
currentMoney = currentMoney - takemoney;
}
What I hoped to accomplish is upon saying you'll buy something in the dialogue system (clicking 'yes' as a response when prompted) the method will run, subtracting an amount from my int currentMoney.
So, I used SendMessage(takemymoney, 5, MoneyManager) in the sequencer on the node after you agree to buy the item. This gives me the following error:
Dialogue System: Lua code 'return SendMessage(takemymoney, 5, MoneyManager)' threw exception 'Invoke function call on non function value.'
UnityEngine.Debug:LogError(Object)
Any suggestions on how to accomplish what I'm attempting?