Home Technical Talk

Creating a driveable vehicle inside of Unity - tutorial

polycounter lvl 15
Offline / Send Message
Polynurb polycounter lvl 15
I created a tutorial for Unity last night. I figured I would share some knowledge I've gained along way, mostly from other contributors on the forum. This tutorial will have you up and running in 20 minutes with a fully driveable vehicle, full on physics and fully tweakable settings. You could use this to create a racing game, a stunt game, or just vehicles for your game. Thought I'd give back to the community a bit.

http://www.youtube.com/user/PolyNurb#p/u/0/21zuMIsy2GM

Replies

  • Brendan
    Offline / Send Message
    Brendan polycounter lvl 8
    bump for a good tutorial. Wheel colliders can take a while, but once you got a base vehicle prefab like that one, you're golden.

    If I might suggest, were you to put that vehicle up on the Asset store for free, you'd help a lot of people. Sure it's easy as pie, but for a lot of people a drag and drop driveable car is like an instant win button.

    Some things to consider...if you're going for a more complex car...


    Wheel hub assembly (wheel-side suspension mounts, wheel-side steering mounts, BRAKE CALIPER)
    > Wheels (with BRAKE DISC)

    The trick is getting the wheel hub to turn left and right, but not rotate. That way the brakes should look OK, ie the disc spinning and the caliper staying the right way up.

    For the suspension, set the pivot at the roll center for that wheel (centerline of the car and the wheels is the easy, but not best, way). Then grab a look at script, point it towards that wheel, and it should follow the wheel up and down as it travels through the suspension movement.

    Alternately, rig the base of the suspension to one bone, then the other end to another bone, and use the lookat script on that bone. There might be some stretching, but it should be alright.
    Hard mode is every suspension component is an individual mesh, and lookat their own points on the wheel hub.

    Steering arm goes the other way; as parent of the wheel hub, have it look at the steering column, or just the centerline of the car at a point along it's z and y axis.

    Now you've got some good looking brakes and suspension that moves like it's actually connected on both ends, you can have better looking open wheel race cars.



    I'm looking forward to your next tutorial about setting them up. Are you going to use the old sway-bar script - it's pretty good for getting the handling right and sorting out bumps.
Sign In or Register to comment.