I have a flying script that works well but I need to be able to adjust the speed to some maximum value when you scroll up and be able to go backwards if you scroll down past zero. Right now I have it where it reads the input of the scroll wheel but it only moves as I roll the scroll wheel and doesn't move when I am not scrolling. How do I get it to change its velocity and not just move it with the scroll wheel? here's the script:
var rotateAmount = -5.0;
function FixedUpdate() {
// Turn
var h = Input.GetAxis("Mouse X");
var v = Input.GetAxis("Mouse Y");
rigidbody.AddRelativeTorque(0, h * 20, v * 20);
// Other way you may like
//transform.Rotate(0, h * 20, v * 20);
engine=Input.GetAxis("Mouse ScrollWheel");
rigidbody.velocity = transform.right * engine*5;
//Also if transform.forward doesn't work try transform.right
if (Input.GetAxis("Horizontal") < 0)
{ transform.Rotate(rotateAmount, 0, 0);
}
else if (Input.GetAxis("Horizontal") > 0) transform.Rotate(-rotateAmount, 0, 0);
}
ignore any odd negatives. My model had some of the axis backwards so I had to switch some signs. Hope someone can help! Thanks:)
it already goes forward and rolls with the a and d keys. the part that says rigidbody.velocity = transform.right * -10; is what controls it moving forward with the 10 being the velocity. i'll take a look at this though.
– cidmodderyup it does. its bed time for me but i'll play with this tomorrow. thanks!
– cidmodderI made some changes. I can't get the scroll wheel to work properly. I can get it to read the input and all but not actually change the velocity just move it when I scroll.
– cidmodder