- Home /
How to make a Java script restart?
How do I make my Java Script randomly trigger or restart every ... let's say 6 seconds?
Comment
Answer by valax · Aug 27, 2012 at 05:48 PM
You can use invoke repeating to repeat a function. Example:
var projectile : Rigidbody;
InvokeRepeating("LaunchProjectile", 6, 6);
function LaunchProjectile () {
var instance : Rigidbody = Instantiate(projectile);
instance.velocity = Random.insideUnitSphere * 5;
}
This will wait 6 seconds (as soon as the play button is pressed) and then activate 'LaunchProjectile' function, it'll repeat the same function every 6 seconds too.
Your answer
Follow this Question
Related Questions
Random Java Script Activation? 1 Answer
Play parent animation without affecting the child animation 1 Answer
Trigger Script Not Firing 4 Answers
Low gravity on trigger. 2 Answers
how to make triger fireball not to pass through spesific objects 2 Answers