- Home /
 
               Question by 
               ratboy · Feb 13, 2012 at 10:15 PM · 
                accelerationmathf.clampconstantmotor  
              
 
              how to clamp acceleration?
Hi guys, I need to give my vehicle an automatic acceleration up to a certain point, im pretty sure i need to use Mathf.Clamp but i'm not sure how to script it properly. The player doesnt control the speed, but my script currently has a user input to make it accelerate.
 function FixedUpdate () {
 //query input axes if necessarry
 if(queryUserInput)
 {
     brake = Mathf.Clamp01(-Input.GetAxis("Vertical"));
     //handbrake = Input.GetButton("Jump")?1.0:0.0;
     //steer = Input.GetAxis("Horizontal");
      motor = Mathf.Clamp01(Input.GetAxis("Vertical"));
  }
 else
 {
     motor = 0;
     //steer = 0;
     brake = 0;
     //handbrake = 0;
 }
I need to change this motor into an automatic motor that never goes above a certain speed. If someone could help me out with the basic script I'll of course edit the values myself, just need a start. Cheers - monster.
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by blacksnow · Apr 09, 2012 at 05:34 AM
this link will definitely help u
http://unity3d.qatohost.com/questions/173673/car-accelerate-over-time-javascript-and-rigidbody.html
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                