Game Development Community

Scheduling Recurring Event

by Dumbledore · in Torque Game Engine · 07/17/2008 (2:17 pm) · 2 replies

Sheesh I don't seem to have much luck with the search engine here. Figure I better ask...

Is there a built-in way to schedule a recurring event, because this way isn't efficient because it needlessly deletes and reclaims memory.

void MyEvent::process(SimObject *object)
{
	MyObject* rm = static_cast<MyObject*>(object);
	rm->processSecondElapsed();
	MyEvent* rmEvent = new MyEvent;
	Sim::postEvent(this->destObject, rmEvent, Sim::getCurrentTime() + 1000); 
}

#1
07/17/2008 (2:51 pm)
No, but you could create a new NetEvent inside another object's processTick or on some interval in advanceTime perhaps. That would still have to allocate one each time though... I wouldn't worry about it unless its a truly huge amount of data in your NetEvent.

Or for continuous updates use pack/unpackUpdate in an object. I think internally that is still allocating NetEvents so... i wouldn't worry about it.
#2
07/17/2008 (2:53 pm)
If your object is one that has a processTick, you can build your own recurring event using an internal timer.