Hey all!
This has been bothering me and took me a while to find out but I am making an aircraft vehicle and I have made the controls so it speeds up using simplemove. However simplemove adds gravity and I need to disable the gravity, is there anyway to do this? this is my script so far: (I have taken out some of the extra features such as handbreak etc…)
private var conversionMetrics : float = 9.2;
var vehicleSpeed : float = 0.0;
var topSpeed = 120;
var tireTraction : int = 3;
function Update()
{
var controller : CharacterController = GetComponent(CharacterController);
var moveDirection = transform.TransformDirection(Vector3.forward);
var curSpeed = vehicleSpeed * Input.GetAxis("Vertical");
//Rotate code
transform.Rotate(0, Input.GetAxis("Horizontal") * tireTraction, 0);
//~~~~~~~~~~~~~~~~~~~~~~~~~Increase Speed~~~~~~~~~
if (Input.GetKey("w") || Input.GetKey("up"))
{
if (vehicleSpeed < topSpeed)
{
vehicleSpeed += 1 * Time.deltaTime * conversionMetrics;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Breaking~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (Input.GetKey("s") || Input.GetKey("down"))
{
if (vehicleSpeed > 0)
{
vehicleSpeed -= 5 * Time.deltaTime * conversionMetrics;
if (vehicleSpeed == 3)
{
vehicleSpeed = 0;
}
}
}
if (Input.GetKey("q"))
{
gameObject.transform.position.y += 1 * Time.deltaTime * conversionMetrics;
}
// Move the controller
controller.Move(moveDirection * vehicleSpeed);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I read on-line that to get rid of the gravity I should use move instead, however the only way I can think to keep it moving is by using a boolean for every action. Is there any other way? please and thank you!