Wait Script
5 posts • Page 1 of 1
Wait Script
Is there a script like "wait 3 seconds" or something of that manner?
- b2lego
- Posts: 5
- Joined: Thu Jun 28, 2018 2:59 am
Re: Wait Script
i did a search and i didnt find anything that fit..
- b2lego
- Posts: 5
- Joined: Thu Jun 28, 2018 2:59 am
Re: Wait Script
Example of a 20 seconds timer that change variable to 1 on object collision:
OnCollide
update
If you want a script that execute each 10 seconds on object collision for example put the same "timetolive" value in update too example :
OnCollide
update
Or if you want script execute each 10 seconds for example without nothing happend just leave OnCollide empty and set the timetolive to 0.1 like this example:
OnCollide
timeToLive = 0.1
update
OnCollide
- Code: Select all
(e)=>{timetolive=20}
update
- Code: Select all
(e)=>{timetolive<0.02?{timetolive=∞;scene.my.yourvariable=1}:{}}
If you want a script that execute each 10 seconds on object collision for example put the same "timetolive" value in update too example :
OnCollide
- Code: Select all
(e)=>{timetolive=10}
update
- Code: Select all
(e)=>{timetolive<0.02?{timetolive=10;scene.my.yourvariable=1}:{}}
Or if you want script execute each 10 seconds for example without nothing happend just leave OnCollide empty and set the timetolive to 0.1 like this example:
OnCollide
- Code: Select all
(e)=>{}
timeToLive = 0.1
update
- Code: Select all
(e)=>{timetolive<0.02?{timetolive=20;yourfunction}:{}}
- Skrubs
- Posts: 16
- Joined: Tue Mar 06, 2018 7:36 pm
Re: Wait Script
I usually perform time based scripts using a _timer variable(A custom variable added to the object). First you need to enter "_timer=0" into the small black box at the top left of the script menu to register the _timer variable. Then you use it like this:
Somewhere in poststep:
_timer> 0 ? {
_timer = _timer-1/sim.frequency
} : {
_timer > -1 ? {
_timer = -1;
-->{Your script here}<--
} : {}
}
If you want to trigger the timer, just write _timer = X somewhere and replace X with the time until the script should run. Note that this only works with 1 piece of script for each timer, as such you cant just pause any script anywhere, only trigger a specific piece of code after some delay.
Somewhere in poststep:
_timer> 0 ? {
_timer = _timer-1/sim.frequency
} : {
_timer > -1 ? {
_timer = -1;
-->{Your script here}<--
} : {}
}
If you want to trigger the timer, just write _timer = X somewhere and replace X with the time until the script should run. Note that this only works with 1 piece of script for each timer, as such you cant just pause any script anywhere, only trigger a specific piece of code after some delay.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
5 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests