- Home /
Car Automatically Moving
In my game I have a car racing scene and I have my car perfectly set up and the car its racing has a script that makes it shoot out like a bullet but then eventually slow down and stop. here is that script:
var speed : float = 5.0;
yield WaitForSeconds(6);
rigidbody.velocity = transform.forward * speed;
I know its very simple. Can i Have a script that makes it constantly move? thanks.
"Can I haz script?" No...we don't make scripts here, we answer questions about scripts you've actually tried. You should look into using Update()
or Rigidbody.AddForce()
.
is it in a fixedupdate or update function? why the yield?
Answer by Prodigga · Jun 30, 2012 at 02:30 AM
You code doesn't make much sense for the problem you are trying to solve. You want to look at your Update function more closely; this is where your solution will go.
rigidbody.velocity = transform.forward * speed;
this part is correct, but being used in the wrong place. Try putting it in the update() function and see what happens. :)
Just in case, here is the other answer you gave :
'rigidbody.velocity = transform.forward * speed;` This part is correct but being used in the wrong place. Try to put that line in the Update function and see what happens.
oh cool. i missed the 'your comment is awaiting approval' screen so i re-wrote it as best as i could from memory. thanks for that
Your answer
Follow this Question
Related Questions
Does anyone have figured the WheelFrictionCurve struct ? 2 Answers
Applying Torque to wheelcollider 1 Answer
How to make car accelerate/decelerate over time 2 Answers
Realistically drivable car 0 Answers
Slotcar game 1 Answer