Hi,
I’m using “SendMessage(“decrease”, rate, SendMessageOptions.DontRequireReceiver)” within an update function but I don’t want it to occur every frame, instead only once a second. Also I only want it to be sent while the jump button is held down.
How can I do this?
Thanks, Stu
You should invoke the call for timed functions, running a function every frame will still eat some CPU.
function Start () { InvokeRepeating("sendDecreaseMessage", 0, 1); } function sendDecreaseMessage () { SendMessage("decrease", rate, SendMessageOptions.DontRequireReceiver); }
function Update() { Send(); } function Send() { yield WaitForSeconds(1); if(Input.GetButton(“Jump”)) { SendMessage(“decrease”, rate, SendMessageOptions.DontRequireReceiver); } }