In this example we’ll configure a new car model for the IK Driver prefab using Fantastic Race Car 13 from the asset store, but you can use any vehicle model. https://www.assetstore.unity3d.com/en/#!/content/29461

  1. Open the “IK Driver Day Demo” scene located in the “Assets\TurnTheGameOn\IK Driver\Scenes” folder. This scene contains the IK Driver Demo Controller that spawns and holds a reference to the vehicle controller prefabs.

  1. Duplicate the “IK Driver Left Steering” prefab in the “Assets\TurnTheGameOn\IK Driver\Prefabs” folder, rename it to “IK Driver Tutorial”, then drag it into the scene and disable the “IK Driver Demo Controller”. This is your new vehicle prefab, you can change the name to whatever you like.

  1. Bring your new car model into the scene as a child of the new “IK Driver Tutorial” prefab object. This will replace the current car model named “FST_Master_2DB”. Before we remove the old model, we can use it as a visual reference to scale our new car model to the proper size. Observe the scale of the default vehicle mode, this is scaled to match the real world, use this to determine an appropriate scale value for your model, in this case I increased it to 1.05.

  1. Assign the new wheel mesh objects to the Vehicle Controller script in the same order the default vehicle is assigned: Front Right, Front Left, Rear Right and Rear Left. Then press the “Align Wheel Colliders” button to re-position the vehicle controller’s wheel colliders so that they match the new wheels.

  1. The old vehicle model “FST_Master_2DB” is no longer required, you can delete this and update/apply the changes made to your new vehicle prefab.

  1. Select the Wheel Colliders and adjust their radius, transform.position.y and any other wheel collider setting you might like to better suit your new vehicle type. Click the unity documentation link in the top right corner of the component inspector to learn more about how adjusting these settings will change the vehicle physics properties and create different driving styles for your vehicles.

  1. The vehicle lights use standard Unity light components and are positioned in world space, select and enable the brake, reverse and tail lights, move them back as a group on the z axis in the scene view so they feel about right. You can adjust individual lights more accurately as needed, when finished disable the light objects that you enabled (brake, reverse). Repeat this process for the head lights.

  1. Replace the vehicle collider mesh and make any collider transform adjustments. This vehicle model includes different LOD versions, I will use the body mesh from LOD2 since it’s well optimized and suits this need. This LOD model is not the same scale as the prefab model, it’s far too small; I’ll change the fbx object’s model scale factor to 1 so it matches the prefab vehicle model.

The new model is now configured to work with the vehicle controller; next we’ll adjust a few more additional visual configuration settings to match the new model, including IK targets, avatar, steering wheel and vehicle mirrors transform positions.

  1. Start adjusting the IK and avatar transform positions for a new vehicle by selecting the “IK Driver Avatar”, “IK Steering Wheel” and “IK Objects” at the same time and move the scene view transform handle to bring the avatar into the driver seat.

You can also enter play mode and press “C” to switch to the driver’s helmet camera view as you make this adjustment to test the new positions and make sure you’re moving the objects to a good default setting.

  1. Move the new vehicle’s steering wheel object to be a child of the “IK Steering Wheel” object.

  1. Move, rotate and optionally scale the steering wheel to match the default steering wheel. You can also enter play mode and press “C” to switch to the driver’s helmet camera view and test moving/rotating the IK Target objects. If you’re using the default 2 hand clamped steering option, you only need to adjust “IK Target E” and “IK Target W”.

  1. Disable or remove the old steering wheel called “Steering_Left”, and click apply on the “IK Driver Tutorial” prefab object to apply our changes.

  1. The object “IK Objects” holds the gas, brake, clutch, shift and look targets; the goal is to move and rotate these objects to control how your avatar animates, so the look target gives you a good camera view and the shifter looks like it’s being grabbed and the feet reach for the pedals based on the current vehicle inputs. The default settings are good enough in most cases, however the shifter is often in a different place on most vehicle models.

Select the “IK Target Hand Shift” object, enter play mode then adjust the transform position and test shifting by selecting the shift variable on the “Race Driver” object’s “IKD_IKDriver” script.You can use an additional locked inspector for this object so you can shift and move the IK target without needing to select new objects. Right-click and copy the component transform values and paste them after you exit play mode.

  1. Adjust the rear and side view mirror objects to match the position’s of your new vehicle. You can start by moving them as a group to get them in a general position the individually adjusting them as needed. The shader used for the mirrors uses a texture as a mask that you can create so it fits the shape of your vehicle’s mirror.

IK Driver setup is now complete, you can apply your final changes to the prefab. If you like you can also spend additional time focusing on the details of more precisely aligning any of the objects covered this tutorial. Each IK Target that you move will make the driver animate a bit differently.

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Please do not use this for support questions.
For customer support, please contact us here.

Post Comment