i wrote this simple life script and i tried to implement some kind of “time for restore of health”, for example if i am beaten and i’m still alive but my health value is low, if there is no collision for about two seconds, i want to restore my health
i thought to use python’s time library but i can’t think a way to do this.
here the code:
import bge, time
from bge import logic as l
controller = l.getCurrentController()
own = controller.owner
You can use time.time() on object property ‘lasthit’ on every collision. Then check time.time() - lasthit > 2 * 1000 and health < 30: health += regeneration