mush
New Member
Posts: 39
Posts: 39
|
Post by mush on Jun 28, 2015 1:32:50 GMT
Hello, I was just wondering if it is possible to have the timer start from 0 or reset to zero when i progmatically enable the deathtimer? if I set death timer on killable to 5 seconds and then untick "Use Death Timer" then in code when the time is right i set the death timer back on with: var kill = binder2.GetComponent<Killable>(); kill.timerDeathEnabled = true; the killable instantly dies. - it does not start from 0 and count 5 seconds. I have tried reverse logic where i initially tick the "Use Death Timer" and set it for 5 seconds. Then at the start of the scene i disable the death timer var kill = binder2.GetComponent<Killable>(); kill.timerDeathEnabled = false; this works great and turns the timer off. But when I want to turn back on again with code they instantly die. P.S. The new death/damage vector offsets are absolutely awesome - way more control over how child prefabs spawn now 
|
|
|
Post by DarkTonic Dev on Jun 28, 2015 4:50:53 GMT
Yeah, you shouldn't really ever be setting variables (like timerDeathEnabled) in Killable. Usually features are a combination of a bunch of variables. Only use methods and properties to do what you want (those are the only ones that show on the API website). Unfortunately I have to make most variables public so our Custom Inspector can use them.
As a temp fix, you can make this variable public instead of private on line 172 of Killable:
private float _spawnTime;
And then make sure to set _spawnTime to Time.time when you re-enable timeDeathEnabled. Like this:
var kill = binder2.GetComponent<Killable>(); kill.timerDeathEnabled = false; kill._spawnTime = Time.time;
In the next version I'll add a methods "StartDeathTimer" and "StopDeathTimer" to make this easier.
|
|
mush
New Member
Posts: 39
Posts: 39
|
Post by mush on Jun 29, 2015 23:52:54 GMT
Thanks that works perfectly!
|
|
|
Post by DarkTonic Dev on Jun 30, 2015 0:30:22 GMT
No problem.
|
|