- Home /
Car NOS Boost
I'm doing a racing game and i was wondering if anyone knew how i could do a speed boost. I'm fairly new to Unity so i don't really know what i'm doing.
I'm building this upon the car tutorial so that I don't have to rebuild the terrain or the car.
Answer by TSorbera · Apr 26, 2012 at 02:49 PM
I'll be giving you general help to help you learn, rather than looking up this tutorial and telling you the exact code.
Find the code that makes the car go when you press the accelerator button. Somewhere it will define how fast the car goes. Add a condition that if the boost is active, probably triggered by a Button press, the speed or acceleration rate of the car should be higher.
I added the following code: var SpeedBoost : float 900;
and function GetButtonDown (LeftShift) { update topSpeed : float SpeedBoost; }
But when I go to try and test this code, I get an error saying that it was expecting a semicolon after "update topSpeed : float SpeedBoost". I've tried various other ways but haven't been able to get rid of this error.
I still have the error saying "Assets/Scripts/JavaScripts/Car.js(74,15): UCE0001:';' expected. Insert a semicolon at the end. The line of code that is creating this error is: " function GetButtonDown (LeftShift) { update topSpeed = float SpeedBoost; } "
Answer by AusAndrew19 · Aug 22, 2013 at 02:30 PM
Sorry For Grave Digging. But i thought i would answer this so other people could see it aswell.. This isn't the best way to do "NOS" But it works :)
#pragma strict
var isReady : boolean = true;
var activateSound : AudioClip;
var vehicle : GameObject;
var waitTime : float;
function Start () {
}
function Update () {
if(Input.GetKeyDown("left shift") && isReady){
Nitrous();
}
}
function Nitrous () {
audio.PlayOneShot(activateSound, 1);
isReady = false;
vehicle.rigidbody.AddForce(transform.forward * 1000, ForceMode.Acceleration);
yield WaitForSeconds(waitTime);
isReady = true;
}
Answer by arwe2793 · Apr 18, 2014 at 07:00 PM
you could try this http://www.youtube.com/watch?v=oZWCg9pM7Bc&list=UUJNI1KRjHTRY66qThiKSU5Q its free with nitro effect
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How can i rotate my car steering wheel in accordance to the wheels? 1 Answer
TOP down 2d car physics 0 Answers
stabilize car? help! 0 Answers
Switching from player to car 2 Answers