UE3:Vehicle Tutorial (UDK)

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 20:22, 19 January 2010 by Dance (talk | contribs)

Vehicle Tutorial

This is a step-by-step tutorial on how to model, rig, export and script a custom four wheeled vehicle. Also this work is a combination of several tutorials on the subject so we by no means take credit for everything but only want to help others.


Part 1: Design

We have not explored all the different design types that can be done in UDK but it seems it is broad depending on the game you are making. Of course don't expect a low riding vehicle to cross terrain that will make it bottom out. But if your roads are flat then a low riding vehicle should be fine. The vehicle in this tutorial is pretty low but only have tested it in a empty room with a flat surface and seems to work fine. Also lowering the wheel bones to there lowest point helps when you need more suspension.


Part 2: Rough Model and Basic Vehicle Setup

I started with a box type car very basic model with basic tires and basic suspension. I did this just in case i had to make a lot of changes to get it to work and to avoid wasting time in case i had to start from scratch like i did several times.


Naming

Get with your programmer and mapper and decide what names you all are going to use for the bones to save everyone time in the long run. Your programmer will have to add the bones names in the script and the mapper will have to add the names to connect the bones to the controllers and the mesh in the editor. So if you change the names of your bones when you rig your model everyone else will have to change the names. Naming your objects when modeling will not be important because you will be merging them into one mesh when you are done and will be naming that mesh on export.


Modeling

When you make your model just create your separate objects like normal body, tires, suspension. Then after you are satisfied with your model you will need to merge the objects into one. I know it doesn't seem logical that you are going to use one mesh and that your tires will be able to rotate versus making your animated objects as separate meshes and exporting them separate. Also I would suggest you duplicate and hide the original objects in case you have to go back and make changes. I normally put all my objects under a parent object/model and hide them before i make major changes or just save the scene as a different file name. Note: You will want to make sure you are thinking ahead instead of just going wild with your model and later having to go back and fix it because it is too hard to animate.


Scaling

You will want to scale your model to the scale of a ingame character. You can always make adjustments to the scale later but i would advice against it unless you are a advanced user in your 3d program. All 3d apps are different so try exporting a static mesh and adjust it to a ingame character. Don't adjust it ingame just compare it to the ingame environment then adjust the units/meters/inches in your 3d app so you know what measurements you are going to need to make it look right ingame.


Aligning

You will want your mesh to align so your vehicles length extends into the X axis it's width into the Y and height into the Z. So in other words the front of your vehicle need to be pointing towards the X axis and the roof pointing on the Z axis and the doors on the Y axis in UDK. Now in your 3d app might be totally different for example in Softimage the front of the car points on the X axis and the hood points on the Y axis and the doors point on the Z axis. You will want to do the same as you did for scaling import it as a static mesh and make sure it as the correct alignment. Keep in mind that when you add bones you will need them aligned the same way as the mesh.


Texturing

Depending on your 3d app you can texture your model before or after you rig it. I would suggest for your first test model just use a standard uv map to avoid spending too much time appling texture maps. Also I used a 1024^2 texture map and mapped the whole model using a "Unique UV polymesh" but using a box map for the whole mesh should be good enough. Once you are more familiar with the whole process that's when you should go back and unwrap the model properly and texture it.


Rigging

Now first thing when rigging is that you can use nulls or bones at least this is the case in Softimage. I prefer using nulls seeing there are no roots or effectors you have to mess with. Also make sure your the bones align correctly in UDK they should be aligning in the same direction as your mesh so when you open in the editor the mesh and bones are pointing in same direction. I tested it first just using the root bone and apply the whole skin to the root bone so you can export and test it. Note: You might have to rotate the bone like i did to a -90 so it aligns right in the editor. Then i rename the root bone to Main_Root and after i knew it was aligning correctly i then made a copy of the Main_Root bone and moved it to the back tire for the back tire bone and renamed it B_R_Tire, then i copied the back tire bone and moved it to back axle for the back axle bone and renamed it B_R_Axle, then i copied both the back tire bone and back axle bone and moved them both to the front and renamed them F_R_Tire and F_R_Axle and i repeated same thing on the left side of the car.


Skinning

You need to attach your skin to the appropriate vertices. For example your root skin needs to attach to the vertices of the body of the vehicle. And your wheel skin needs to attach to each wheel according to its matching bone. Each 3d app has its own methods of attaching the skin to bones. In Softimage i attached the mesh to all the bones and reassigned the vertices to there appropriate bones.


Exporting

First you will need to install ActorX.


Part 3: Editor Setup

Part 4: Scripting

Tips

Inverted Mesh: I came across this several times for some reason when you apply the envelopes and start attaching the bones to the mesh your mesh gets inverted and when you load it into editor you can only see the back faces of the mesh. Now there is a option in ActorX exporter under the "Setup" tab that has a (Invert) option but it never worked for me.


Video

SimpleCar Youtube
Quad Youtube

Project Files

SimpleCar.rar
Fileplanet
Megaupload
My Site "Last Resort Link" <uscript> Contents: The names are different SimpleCar/Humvee/VH_HMMWV because we did not want to go back and rename everything.

Folder SimpleCar Folder C.UDK.UDK.2009-12.UTGame.Content.Vehicles File VH_Humvee.upk

Folder C.UDK.UDK-2009-12.Development.Src.MyMod.Classes File UTVehicle_Humvee_Content.uc File UTVehicleFactory_Humvee.uc File UTVehicleHumvee.uc File UTVehicleHumveeWheel.uc

Folder Humvee Export Model File VH_HMMWV.psa File VH_HMMWV.PSK File X_ModelInfo_VH_HMMWV.LOG

Folder Humvee Model Source File Humbvee.ase File Humbvee.dae File Humbvee.fbx File Humbvee.mtl File Humbvee.obj File Humbvee.xsi File simplecartexture.bmp </uscript>