Cogito, ergo sum

UE3:Vehicle Tutorial (UDK)

From Unreal Wiki, The Unreal Engine Documentation Site
(Redirected from UDK/Vehicle Tutorial)
Jump to: navigation, search

Vehicle Tutorial[edit]

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[edit]

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[edit]

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[edit]

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[edit]

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/blend 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[edit]

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[edit]

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[edit]

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[edit]

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 the bones aligning correctly in the editor 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 i could export and test it. Note: You might have to rotate the bone like i did to a -90 X axis so it aligns correctly in the editor. After that i renamed 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[edit]

You need to attach your bones to the appropriate vertices of your mesh to create the skin. For example your root bone needs to attach to the vertices of the body mesh, and your tire bone needs to attach to the vertices of your tire mesh and repeat the process until you have covered the entire mesh. When you finish your mesh weights should be color coded to the bones so when you look at it you should see the body one solid color the tire one solid color each should have their own colors. If you see any blending in the colors then you have applied to wrong or went too far and you will notice it when you see it animating funky. Each 3d app has its own methods of attaching the vertices to the bones, in Softimage i attached the mesh to all the bones and reassigned the vertices to there appropriate bones. Note: You will need to parent your bones under the root bone before you export you might need to parent them before applying the skin that will depend on the 3d app.


Exporting[edit]

First you will need to install ActorX.

Part 3: Editor Setup[edit]

I did not do anything special when i setup the SimpleCar package basically i just opened the Scorpion package and tried to copy as much of the settings as i could, but there where some of the settings that i could not use for me package because the animations where not the same but the basic setting where.

Naming[edit]

Make sure you are using the correct names for your package and content get with your programmer and modeler to find out what the naming convention is before you get started. This is very important because the scripts will be reading the info in the package and you will need to know the bone names when adding controllers and what not.


Packaging[edit]

Create a test map or open an existing map i would suggest a simple map so it loads rather quick because you might be opening and closing it a lot. Now that the map is open you can open your "Content Browser" this is where you will be spending most of your time. Go ahead and import your .psk file which is the (SkeletalMesh) file and click ok when the dialog box appears, now import your texture map and when dialog box appears check the "Create Material?" box so it creates the material for you. After you have imported those 2 items save your package and name it accordingly because if you don't save it then something might happen and you could lose the entire package or learn the hard way :)...



Part 4: Scripting[edit]

WIP...


Tips[edit]

Build: UDK-2009-12

Compile: In order for Unreal to compile your scripts in MyMod folder you need to make sure that ;ModEditPackages=MyMod is not nulled out in DefaultEngine.ini Just right click the file and go to properties and uncheck Read-only then open the file and change ;ModEditPackages=MyMod to ModEditPackages=MyMod just remove the (;).

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. I found that if you reset the mesh transformations after you finish modeling and merging into one object it usually helps. What i mean by resetting is make a cube that expands over the whole vehicle and merge it with the vehicle then delete the cube and your vehicle transformations should have reset.


Videos[edit]

SimpleCar Youtube
Quad Youtube


Forum Topic[edit]

If you have any questions just post them on this forum topic... Step by Step Tutorial


Project Files[edit]

SimpleCar.rar
Fileplanet
Megaupload

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