Tuesday, August 20, 2013

UNITY: Creating a Driveable Vehicle in Unity 3D (youtube)

http://www.youtube.com/watch?v=21zuMIsy2GM&feature=youtube_gdata_player

Notes:

MAYA:

  • make sure units are set to METERS so that units are 1:1 with Unity.
  • Length and Width: 5.0 units
  • Grid Lines every: 1.0 units

  • Average car is about 4m long, 1.5m wide.
  • label your body and wheels.
  • Delete History and Freeze Transformations.
  • Move model to properly sit on ground plane in Maya (keep transform)
  • export FBX (to Unity folder if you'd like)

    • mesh
    • units: meters, scale factor of 1.0
UNITY:
  • import FBX model into "ASSETS" folder.
  • enter scale factor of 1.0 under model's inspector panel.
  • turn off keyframe reduction.
  • hit APPLY to save information (important!)
  • drag icon into Unity scene.
  • FBX Export automatically creates group node, but in this case we don't need it so pull the assets out of the group node.
  • directly parent wheels under CHASSIS of car
    • chassis >
      • wheel_frontLeft
      • wheel_frontRight
      • wheel_rearLeft
      • wheel_rearRight
  • insert ground plane
  • zero out ground plane transforms (0,0,0)
  • (optional) add texture to ground plane
  • create empty GameObject and name it "WheelColliders"
  • zero out node to (0,0,0)
  • duplicate and name "FL_WheelCollider", which will be a template for the rest of the wheels.
  • Add GameObject>WheelCollider to "FL_WheelCollider"
  • Duplicate to the following structure:
    • WheelColliders>
      • FL_WheelCollider
      • FR_WheelCollider
      • RL_WheelCollider
      • RR_WheelCollider
  • line up all WheelColliders with actual wheel art assets
    • move CENTER xyz via INSPECTOR, not through the Scene View.[ !! ]
    • size using RADIUS
    • rinse + repeat for other wheels, with given information (size, position)
  • Add Rigidbody to CHASSIS of car object (top group)
    • change mass to 2000 (Unity units are metric, mass in KG)
    • interpolate set to "interpolate" (smooths out collisions)
  • Add BoxCollider to CHASSIS
    • (from different tutorial)
      • rough out the collision shape of your vehicle
  • Add CarScript to CHASSIS
    • configure front Left and Right wheels for steering (script dependent)
    • configure GEARS
      • number of gears
      • gear ratios
        • 4.31, 2.71, 1.80, 1.41, 1.13, 0.93 (basic 6 speed)
      • engine torque: 90
  • Add WheelAlignment Script to each of the wheel geometry
    • input corresponding Wheel Collider per wheel
  • Add Audio source (Car script calls for it)
BAM. Car.

No comments: