Question by
Salamander24 · Apr 08, 2017 at 12:50 AM ·
javascriptdelaypong
Hi,so i'm new to unity and I need help on delaying an object
So i'm trying to remake pong for practice and I want to delay the ball from moving when the game starts. I want to delay it by 3 seconds and this is what I have now (written in unity JavaScript)
var rb : Rigidbody2D; var speed : float = 10;
function Start() { rb.AddForce(new Vector3(Random.Range(-80,80)/10,Random.Range(-80,80)/10,0)*speed); }
Comment
Answer by Salamander24 · Apr 08, 2017 at 02:48 AM
For all of those who want to know, I figured it out by asking a friend and it will work like this
var rb : Rigidbody2D; var speed : float = 10;
function Start(){ yield WaitForSeconds(3); rb.AddForce(new Vector3(Random.Range(-80,80)/10,Random.Range(-80,80)/10,0)*speed); }