Actor's LifeSpan

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
45
Look outside your window!
Visit site
Hi, I have a question and I would appreciate it if any one of you can help me with this. Anyways, my question is:

Is there a way to track the remaining time an actor has after it has been spawned. In my case this is a rocket, a sub class of a RocketMk2. What I want to do is, find a way to track it's remaining time in the world after it's spawned, and to make things more realistic, call it's "Explode" function about a second before it's expiration, instead of the rocked dissapearing all of the sudden.

Is the LifeSpan variable used only to set the...well, life span of the actor, or does it also keeps track of it? Or is there some function that returns this value?
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
The LifeSpan is the time the actor still has left. It keeps track of how much time is left. After the LifeSpan reaches 0 the Expired() function is called and the actor gets destroyed.
 

EasyRaider

Crazy coder
Sep 21, 2001
74
0
0
43
Norway
Originally posted by Brood_of_Evil
So if I write:

Timer()
{
//some code here

if(MyActor.LifeSpan == 1)
SomeFunction();
}

Will it execute the function when one second is left before it expires?

A LifeSpan of 1.0 is a second right?

That code won't work. SomeFunction() will only be called if LifeSpan is exactly equal to 1, which is most likely not the case. Generally, the == operator should be avoided when dealing with floats.

Yes, LifeSpan is measured in seconds.

[edit]
And yes, I believe you should use Expired().