Hello,
I am having difficulties trying to program a delay in execution.
My objective
1. Hide an object on Touch (actor Other)
2. Wait
3. Unhide the object
My problem
I tried two methods for doing it (SetTimer->Timer and Sleep, using states). I was able to achieve the desired functionality except that the waiting time is always 4 seconds or less. This is not long enough for me, I want a waiting time of 30 seconds or more (to simulate a respawning resource).
Here is part of my code using SetTimer
Here is part of my code using Sleep with a state
Results
Both of these codes successfully hide an object on Touch, and unhide it again in 4 seconds. However, trying to increase the waiting time to anything between 5 seconds and 10 seconds only hides the object on Touch, and does not unhide it.
Can you please help me understand what is going on ?
Cheers!
I am having difficulties trying to program a delay in execution.
My objective
1. Hide an object on Touch (actor Other)
2. Wait
3. Unhide the object
My problem
I tried two methods for doing it (SetTimer->Timer and Sleep, using states). I was able to achieve the desired functionality except that the waiting time is always 4 seconds or less. This is not long enough for me, I want a waiting time of 30 seconds or more (to simulate a respawning resource).
Here is part of my code using SetTimer
Code:
function Touch (actor Other)
{
if (bHidden == false)
{
SetTimer(4.0,false);
bHidden = true;
}
}
function Timer ()
{
bHidden = false;
}
Here is part of my code using Sleep with a state
Code:
function Touch (actor Other)
{
if (bHidden == false)
{
GotoState ('RespawnNectar');
}
}
state RespawnNectar
{
function Hide ()
{
bHidden = true;
}
function Unhide ()
{
bHidden = false;
}
Begin:
Hide ();
Sleep (4);
Unhide ();
}
Results
Both of these codes successfully hide an object on Touch, and unhide it again in 4 seconds. However, trying to increase the waiting time to anything between 5 seconds and 10 seconds only hides the object on Touch, and does not unhide it.
Can you please help me understand what is going on ?
Cheers!