how to deal with collision and time since last collision
#1 GDNet+ - Reputation: 859
Posted 16 March 2013 - 10:53 PM
I have two objects and when they collide I want to have a set time frame e.g. 5 seconds where if the object collides again I am able to check that and after 5 seconds its reset and waits until the next collision happens...
Thanks
#2 Crossbones+ - Reputation: 3860
Posted 17 March 2013 - 06:39 AM
Well this highly depends on your implementation, but, without context, I'd say store a timestamp with each object describing the time of the last collision, and upon collision check that the difference between the timestamp and "now" is less or more than 5 seconds, and handle each case accordingly. Either absolute and relative times are fine here for the timestamp, since you are only interested in time differences.
But as I said, this depends on a lot of things, and a callback may indeed make more sense depending on your programming language, physics engine, API, software architecture, taste, etc..






