- Home /
Question by
cjtouhey · Jun 14, 2018 at 08:10 AM ·
movementrigidbodyvelocitymathf.clamp
My accelerate script ramps up in the inspector but no movement.
Hey,
im working on an accelerator script. In the inspector the values show its working as intended how ever force isnt applied to the rigid body and movement isnt achieved could someone look at my code and shine some light on the problem?
if (Input.GetKeyDown("w"))
{
Speed = accelerate + Mathf.Clamp(Speed, minSpeed, maxSpeed - accelerate);
ship.velocity = transform.forward * Time.deltaTime * Speed;
}
if (Input.GetKeyUp("w"))
{
Speed = -accelerate + Mathf.Clamp(Speed, minSpeed + accelerate, maxSpeed);
ship.velocity = transform.forward * Time.deltaTime * Speed;
}
Thanks for any input
Chris!!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612164737im_/https://answers.unity.com/themes/thub/images/avi.jpg)