Hi there,
Currently I’m using WheelColliders within my game to move my cars around (torque/steer values) but as probably expected my cars roll over pretty much every time I’m changing the direction. I’ve already looked for a solution and I didn’t one which would suffice. As in the topic I would like to achieve the car physics that is implemented in game such as Death Rally (accelerate, steer, etc as well as some jumps). What kind of solution approach would you guys recommend?
Cheers
Its a common problem. Move the center of gravity down
Hi and thanks for an answer,
Unfortunately it helped only slightly. Right now I ended up resigning from the wheelcolliders and simply sliding my box collider over the surface with the use of forward vector and transform.Rotate function. It works better (seldom rolling overs) but I wonder if this sort of approach will have any implications in the future level design. Any thoughts? What kind of a drawbacks this approach can present?
This is the code I’m currently started working on (have been doing million different things lately). As for now I’m trying to push my car (AddForce) into the direction that points my 2d joystick on the screen. My main camera is pointing somewhat downwards (isometric projection) so to have it “aligned” with my world I’m using cross product to get the Z axis aligned. Then projecting the x’s and y’s from joystick output onto the corresponding “aligned” axis. The thing of course is that it doesn’t work as it should. Anyone?
Vector3 moveVector = new Vector3(joystick.position.x, 0.0f, joystick.position.y);
Vector3 fwd = Vector3.Cross(mainCamera.transform.right, Vector3.up);
Vector3 z = Vector3.Project(moveVector, fwd);
Vector3 x = Vector3.Project(moveVector, mainCamera.transform.right);
rigidbody.AddForce(new Vector3(x.x, 0.0f, z.z) * Time.deltaTime);