Battlefield 2 Modding Tutorial 7
Importing and Editing the Basic Car
In this tutorial I will show you how to import the car from the previous tutorial and make all the necessary edits to get it into the game using the Object Editor.
Please note: This tutorial is written to cover the steps for users of both Maya and Max. Where the steps differ, they will be labeled accordingly. Just follow the instructions for whichever program you are using.
This tutorial assumes you have done one of the following: Maya you have completed tutorial 6, Building the Car and have created the file My_Car.mb
Max You have completed tutorial 6, Building the Car Max and have exported the car using the wizard, placing the correct files and textures as directed in the tutorial.
The term importing, when applied to the editor, can be a bit misleading. If you use Maya, then you will import using the editor. If you use Max, you actually export with the BF2 Max tools and just open the object in the editor. We will go through both methods now.
If you are using Max for modeling, skip to the section titled “Max –“
- Launch the editor and select “MyMod” at the startup screen.
- Switch to the Object Editor.
- From the main menu, select “File>Import”.
- In the browser window that pops up, select “My_Car.mb”:
- Press “OK” to begin the import process. A command line window will appear for a few moments and then close again:
Note: if you get an error message at the end of this saying errors have occurred, press “OK” to close this window. Look in the output window at the bottom of the editor for the error messages.
If the error messages are something like “Move failed. Could not find texture file: …”, then you probably don’t have your files, especially the texture files, placed in the correct directories. Remember that the texture directory you get the textures from should be in your RawData path, not the final destination in your mod.
There may also be an error message that starts with “Ignored Warning[Console] : Properties only takes one argument!: …” This error is safe to ignore and just means that there is a space in the name of your computer or the user name. The editor writes the name of the creator to each con file and doesn’t like spaces, but it doesn’t hurt anything.
- After importing, to be sure everything is in the right place, be sure that the “my_car” directory in your mod contains the following files and is in the following path:
Back in the editor, the important thing to look for is that you should now see a folder named “my_car” in the list under “MyMod”, and inside that folder should be a file also named “my_car”:
- You have now completed the importing of the car from the Maya file. Drag the file “my_car” from the list to the main window. (Note: You must drag the actual file to the window, not the folder above it with the same name!)
If you are using Max for modeling, you use the exporter in the BF2 Max tools rather than the import function built into the editor.
This tutorial assumes that you've exported the car from Max and copied the textures folder to the correct place in your mod so that you end up with a directory structure like the following:
- Check the above screenshot to be sure that your directory structure matches and all the files are in the correct places.
- Launch the editor and select MyMod from the Startup Mod window.
- Switch to the Object Editor and expand the MyMod folder to find the folder my_car. Inside this folder you will find a file with the same name:
- Drag the file my_car from the list to the main window. (Note: You must drag the actual file to the window, not the folder above it with the same name!)
Editing the Car:
Now that you've gotten the car into the editor, the following steps are the same regardless of which modeling program you use. There will be a few minor discrepancies that will be noted as we go, but the process is the same.
- If you haven't already, drag the file my_car into the main window of the editor. It should look like this:
Image File: <MyCarImported.jpg>
The Car Wizard: == What we currently have is the basic car with a few basic components. Before we can actually place it in the game, we still need to add some info and set some options. We will do that with the car wizard.
- On the right side of the screen, scroll down until you see a button labeled Wizard.
- Click on this button to open the roll-out.
- In the selection box in this section, click on it and choose Car.
- With Car selected, click the Run Wizard button. A new window will open up labeled My_Car:
Image File: <CarRunWizard.jpg>
There are three sections to the wizard window:
Errors are things that we must fix for the vehicle to work in the game.
Warnings are helpful hints for things that you may or may not want to change.
Utilities are usually things that should be done to make the vehicle work correctly. You can adjust these settings here or individually in the editor itself.
* Expand all three sections and check all the boxes in Errors and Utils. (Its not possible to check the boxes next to Warnings. The window should now look like this:
- After checking all the boxes, press Execute.
- Several windows will pop up with the label Enter string. There is a second label inside each window just above a text entry box. Enter the following for each of the text boxes that come up:
Enter new Camera name You can label this anything you like. I always just append Cam to the end of the name, so in this case it would be my_car_Cam:
- Enter new EntryPoint name This one I always append with Entry
After this another window will pop up saying Util Completed Successfully!. Click on OK to continue.
- Yet another window will come up Labeled Adjust Strength/Damping. This should by default have all the boxes checked. Click OK to continue again:
(Max Users the labels will read whl_BL and so on instead of My_Car_BL.)
- More text entry boxes will come up. Look for the label just above the entry box and do the following:
Enter new damping Set the value to 4:
- Enter new strength Set the value to 30:
Note: These are the values based on the jeep. They are just something to start with. You will most likely want to adjust them later.
- Another window will pop up saying "Util Completed Successfully!". Click on OK again.
- Still another window will open up "Labeled Adjust G rip: Select objects to affect." For now just make sure all boxes are checked. They should be by default:
tut7013.jpg (Max Users the labels will read whl_BL and so on instead of My_Car_BL.)
- Click OK. This brings up another window labeled Enter new grip:
- Take a second to look at the options. These are different kinds of wheels you can apply to your vehicle. When youre done, choose "P G FEngine G rip".
Note: This option is for wheels that are attached to the engine, like the drive wheels on a car. Since we had the checkboxes for all four wheels selected, this turns our car into a 4-wheel drive vehicle, which is fine for now.
- After making your selection, click "OK" again.
- A final "Util Completed Successfully" notice will come up again. Click "OK" to finish using the wizard.
- At this point you should be back to the initial wizard screen. This time click "Done" to close it.
Testing the Default Wizard Options:
At this point we have technically set up everything we need to get the car into the game, but lets take it for a test drive before we go any further.
- On the right side of the editor, scroll back up to the top and click on the button labeled Enable physics. You may see the car bounce a little bit as it settles on the springs we set up for the wheels.
- Click on the button labeled Input just above the previous button. This will allow us to control the car as if we were in the game.
- Before doing anything else, find the drop-down box just below the Input button. Click in this box and select Locked on target. This will make the camera in the editor follow the car wherever it goes. Otherwise you would just drive out of the screen and lose the car. We are now ready to drive the car:
Image File: <TestDriveButtons.jpg>
- Move the cursor so that it is over the main window and press the Spacebar once. (This will not work if the cursor is anywhere else)
You have now toggled Control mode. The editor uses the default BF2 input scheme, so holding down W should make the car move forward, but it doesnt. The car doesnt move at all. This is because there are a few things we need to fix that the wizard doesnt get right.
Setting Additional Default Settings:
We will now make a few additional settings that will fix our broken car.
- As usual, press Escape to exit out of control mode and return the cursor to normal usage.
Note: You may also have to press the Free button on the right side of the screen in order to be able to move the camera around again.
- On the left side in the Resource bar, click on the line labeled My_Car_Engine. You may have to expand my_car if you dont see it.
(Max Users This will be labeled zMotor instead of My_Car_Engine.)
- With "zMotor" selected, go to the Tweak bar and expand the section labeled Physics.
- Look about half-way down for the entry labeled "EngineType". Click on the box to the right and change this to "NewCar2". Look at the following screenshot for where to find these entries:
Image File: <EngineNewCar2.jpg>
The reason we need to do this is because NewCar2 is a type of engine that was added to the game after the wizard was created. By default the wizard sets the engine to NewCar (or Car if you are using Max), which is no longer used by the game.
Note: when working with the resource and Tweak bars, you may sometimes have to make them wider to get at the entries. You can do this by holding your cursor over the vertical edge of the window until it becomes a pair of horizontal arrows, then drag to make the window wider. In the above screenshot I've make the windows pretty wide so you can see the entries.
We are now ready for another test drive.
- Over on the right, locate the button labeled Reload Object and press it.
You may notice the car jump a bit. We do this to apply the changes we just made to the engine. This isnt always strictly necessary, but if you find youve made some changes and there doesnt seem to be any difference to your vehicle, try pressing this button to be sure all your changes were applied.
- Reloading the object resets some of the buttons on the right, so click on Input again and make sure that "Enable Physics" is still active. Also make sure that the camera follow mode is still set to "Locked on target".
- Make sure the cursor is over the main window and press the Spacebar again. Now you should be able to drive around using the default W, S, A, and D keys.
Oops! The car move forwards and backwards now, but doesn't turn. That's because the wizard pretty much only sets options that are necessary to get the vehicle into the game. We still have to set up some rotation on the steering.
Setting up the Steering:
- Press Escape to get out of control mode.
- In the Resources window, expand the "zMotor".
- Find the entries labeled "whl_Nav_FL" and "whl_Nav_FR"
These are the rotational bundles that were set up in the modeling program for steering. "nav" means "navigation", which is just a fancy way of saying "steering".
- Click on "whl_Nav_FL" to bring up the values assigned to it in the Tweak bar.
- In the Tweak bar, expand the entry for Rotation.
The first two entries in this section are "MinRotation" and "MaxRotation". We will use these to set up the minimum and maximum that each wheel can turn to the left and right.
- Expand the "MinRotation" entry.
Notice there are 3 separate entry fields labeled X, Y, and Z. In almost all the Battlefield files, these three numbers stand for either translation or rotation. In this instance they are rotation and stand for Yaw, Pitch, and Roll, respectively. (Yaw is basically turning left or right while Pitch is rotating up and down. Roll doesn't often get used.)
- In this case we want to set the minimum Yaw for the wheel, or how far left it will turn, So click on the box next to X under "MinRotation", enter "-30", and hit return.
- Now do the same for "MaxRotation", setting the "X" value to "30".
We have now set up the Front-Left wheel to turn a maximum of 30 degrees to the left and right. There are more settings though, so lets continue.
- Locate the entry labeled "MaxSpeed" and expand it.
- Enter "40" into the "X" field.
This is how fast the wheel will turn.
- Locate the entry labeled "Acceleration" a little further down, expand it, and enter "80" into "X".
Since you are using a keyboard for input instead of a steering wheel, this is a way to simulate steering. Acceleration in this case is similar to the engine: the longer you hold down the key, the faster the wheel turns until it reaches its maximum setting. You will have to play with these settings until you get them the way you like them.
Notice that in all these entries, we have been entering numbers in the X field. These are all Yaw values. Make sure that you keep them straight because they all correspond to each other. If the rotational bundle was something like a gun turret that rotated in both the X and Y axis, you would have numbers in both these fields.
- Locate the entry labeled "InputToYaw". This is where you tell the game which keys to use to control what. In this case the Yaw input is the steering.
- Click on the field to the right where it says "PINone" and change this to "PIYaw", which stands for Player Input Yaw. (Its the very first entry in the list, so you have to scroll to the top of the drop-down window.)
- The last thing to do is locate the entry just a bit below this labeled "AutomaticReset". Check the box to the right of it to turn the option on.
What this does is automatically return the wheels to their default position of pointing straight forward when we stop pressing the steering buttons. If we didn't do this, the car would keep spinning in circles every time we stopped pressing the button.
If you had any trouble following the above directions, look at this screenshot. I've highlighted everything you need to set with the correct values:
Image File: <SteeringSettings.jpg>
Now select My_Car_nav_FR in the Resource bar and do the same for the Front-Right wheel. Make sure that all settings are exactly the same. Give it a test drive again and try out the steering. Don't forget to click the Reload Object button if the changes don't seem to be working. You also may wish to click Reset Vehicle Position if you had previously driven the car off into the distance. You should now be able to drive the car all over the grid.
Note that the wheels may tend to slip a little on the surface. This is because of the default material used on the grid in the editor. The only way to get a real feel for how it handles is in the game itself, which we will get to later. The editor just provides an approximation.
Editing the Engine:
You've probably also noticed by now that the car moves rather slow and doesn't seem to have much power. Well change that now.
- Press Escape to get out of control mode again. You may also wish to press the Reset Vehicle Position button to return the car to the center of the grid. If your camera control is still set to Locked on target, the camera will be pointed at the car. If not, you may also want to click on Zoom to Object. This moves the camera back to point at the car.
- In the Resources bar, click on zMotor again.
- In the Tweak bar, expand the Physics section.
- In the Physics section, set the following values:
Use the following screenshot as a guide:
Image File: <EngPhysicsSettings.jpg>
- Once you've changed these settings, scroll down in the Tweak bar and expand the Rotation section.
The rotation settings for an engine work slightly differently than when applied to a rotational bundle. In this case the entries are actually used as a kind of throttle. All these settings will be explained in detail in a separate tutorial.
- In the Rotation section, set the following values (Notice that you are changing the Z value for most of these):
Use the following screenshot as a guide:
Image File: <EngRotSettings.jpg>
All other settings should be left at their defaults. You are now ready for another test drive. Use the previous technique to drive around again and notice the difference. The car will be much zippier now, both in forwards and reverse. We are still having a bit of a problem with the front tires seeming to slip a bit, causing it not to turn sharp corners very well. Remember that this is only an approximation and that final testing still needs to be done in the game itself.
Assigning Materials and Armor:
We have finished with the engine. Now its time to edit the materials and armor component of the vehicle.
Press Escape again to exit control mode and optionally press Reset Vehicle Position again if necessary to return your car to the center of the window.
- In the Resources bar, select my_car again to select the root of the file.
- In the Tweak bar, expand the section labeled Default.
- At the bottom of the Default section is an entry labeled MapMaterials. Click on the "...' to the right of the name. This will open up a material assignment window.
There will be two entries in this window, Rubber and light_armored_vehicle. These names come from the shaders we created when we modeled the car.
- Click on the boxes labeled Default to the right of Rubber and change the material to rubber. Do the same for light_armored_vehicle, changing the material to Armor_5_light_tank_front. The window should now look like this:
Image File: <CarMatAssignments.jpg>
Note that we originally called the material on the main body light_armored_vehicle, but we are assigning a heavier tank armor instead. The initial names are just labels to tell you whats what. You can assign whatever material you want to them.
You wont see much difference in the editor, but this step is important to make the tires grip the terrain correctly and also is necessary for material effects, such as dust and mud that get kicked up by the tires when they go over different surfaces.
- With "my_car" still selected in the Resource bar, right-click on any of the entries in the Tweak bar. This will bring up a list of things you can add in the Tweak bar.
- Select "Add Armor Component":
Image File: <AddArmor.jpg>
- Expand the newly-created "Armor[Component]" section and change "HitPoints" and "MaxHitPoints" to 300. You can leave all other settings at their defaults:
Image File: <MyCarArmorSettings.jpg>
You should now be able to shoot at it without crashing the game. We have not created an actual wreck LOD yet, so the car will just disappear when its destroyed.
Editing the Camera, Entry, and exit settings:
You may think that we've covered everything, but there still are a few final details we need to take care of.
- Reset the vehicle position if you haven't already, and this time instead of pressing the Input button, press the Enter button just to the right of it instead. You should now see something similar to this:
Image File: <CarCamDefault.jpg>
Whats happening is that we added a drivers camera when we used the car wizard, but its been placed at the origin of the car by default. Since we havent created a dashboard or anything yet, were going to move it up temporarily so that your view is from just outside the car. In a later tutorial when we create a proper first-person LOD0, well change it to a more appropriate view.
- Press Escape if you need to get out of control mode, then press the Free button to the left of Input. You may also need to reset the car position and so on in order to see the car again.
- In the Resource bar, select my_car_Cam. Remember when we created that in the wizard?
- In the main window, you will notice a manipulation handle appear that consists of three different arrows coming out of a small red box. This is the pivot point of the vehicles camera. Click on the arrows and drag up and slightly back to move the point to just above the roof of the car:
Image File: <CarCamMoved.jpg>
- Now with the camera still selected, expand the Rotation section in the Tweak bar and set the following:
* Lastly, check the box next to RestoreRotationOnExit. (This resets the camera to straight ahead when you exit the vehicle.)
Use the following screenshot as a guide:
Image File: <CarCamRotSettings.jpg>
These are the settings that let you look around while you are driving the car. If you dont set them, you will only be able to look straight ahead.
- Back in the Resource bar, select my_car_Entry, just below my_car_Cam.
- In the Tweak bar, expand the Camera section and change the number to 5.
Even though the section is labeled Camera, this is actually where you set the radius of the entry point of the car. The default value of 3 is probably big enough, but now you know how to change it. You can also move this entry point the same way you did the camera by using the pivot point manipulator in the main window.
- In the Resource Bar, select my_car and expand the PlayerControlObject section in the Tweak bar.
- Find the entry for SoldierExitPosition and change this to -2/0/0:
Image File: <ExitSettings.jpg>
- Select File>Save from the main menu to save your work.
Placing the Car in a Map:
We are now finally ready to place our new vehicle in a map for testing.
- Switch to the Level editor and load a level that you want to test the car in.
- In the main window of the Level editor, right-click somewhere close to a control point and choose Create ObjectSpawner. A window labeled Select Vehicle Type will open up.
- The name of our car wont show up in this list, so just choose anything and click OK.
- Another window will pop up where you can enter a name. Change this name to My_Car.
Click OK again, and whatever vehicle you chose will appear on the map.
- At this point the vehicle you chose should still be selected. If not, reselect it, and in the Tweak bar, locate the entries labeled Vehicle Team1 and Vehicle Team2.
- Click on each of these entries and chose my_car from the list that pops up. The car should now replace the vehicle that was originally placed. This is how you get any vehicle or stationary weapon into the game that doesnt appear in the default list. You should now see something like this:
Image File: <MyCarPlaced.jpg>
Note: the car may look a bit funny with the wheels out of place. This is because the editor doesnt properly update the positions of sub-objects correctly. You may wish to click on the Snap object(s) button on the right side of the editor if you want to be sure the vehicle is positioned correctly. The wheels wont move, but it should be okay.
- Select File>Save All from the main menu.
- If you package your maps before testing, and its probably a good idea to get in the habit, then select Mod>Package Mod, also from the main menu.
- In the window that comes up labeled Package MOD Archives, make sure that both package level and package mod are checked, then click OK.
Note: Remember that once you package something once, you have to always package it in the future. Also dont forget to do Save All BEFORE you package. Otherwise the changes wont get added to the packaged files.
You should now be ready to test. Quit the editor, launch the mod, activate your map, and have fun.
Image File: <MyCarInGame01.jpg>
Image File: <MyCarInGame02.jpg>