Hi, not sure if my title is clear enough.
I’m making a racing game inspired by the airplane parts in Diddy Kong Racing and the pod racing in Star Wars Episode 1 Racer.
My code worked pretty well with using translate to move the plane, but since i needed collisions i changed that to rigidbody.addForce. (the -1 is needed because i… uh messed up the direction when modeling my test vehicle :P)
rigidbody.AddForce (this.transform.forward * (-1) * acceleration, ForceMode.Acceleration);
Now i have a problem since whenever i turn the plane it keeps sliding forward until the velocity from the original direction disappears, also it takes a while until there is enough velocity into the new direction. I tried working around with drag, but while it makes away with the sliding, it makes the acceleration at the start and when turning unbearable.
My Horizontal turning code:
transform.Rotate (new Vector3 (0, horizontalRotateStrength * horizontalRotationDirection * Time.deltaTime, 0), Space.World);
I quickly got a solution for that from a friend
rigidbody.velocity = Quaternion.Euler(new Vector3 (0, horizontalRotateStrength * horizontalRotation * Time.deltaTime, 0)) * rigidbody.velocity;
it actually works well enough, but it’s not applicable to the vertical rotation which works like this:
transform.localEulerAngles = new Vector3 (Mathf.LerpAngle (transform.localEulerAngles.x, invertY * verticalRotationDirection * maxVerticalRotation, Time.deltaTime * verticalRotateStrength), transform.localEulerAngles.y, transform.localEulerAngles.z);
Any ideas how to solve the problem? It feels like a problem that should be simple to solve, but somehow i’m drawing a blank
P.S. I also use addForce to simulate gravity among other things. I imagine that could make things more difficult, maybe.