Creating A Custom Car in CryEngine 3 Part Two: Creating the Vehicle Definition in CryEngine

Creating A Custom Car in CryEngine 3

Part Two: Creating the Vehicle Definition in CryEngine

Introduction

In this tutorial, I will be covering how to create a vehicle definition in CryEngine by writing a .xml file for the Vehicle.  The easiest way to do this is to modify an existing vehice .xml.  We are going to use the HMMWV.xml as a starting point and edit individual <Tags> one at a time to solve specific problems.

I have found it easier to edit the .xml in a text editor than to use the Vehicle Editor.  If you want to try the Vehicle Editor out it can be found under the View>Open View Pane menu.

  1. To get started we will add a reference to our custom vehicle model.  Under the <Parts> tag find the following line.  
    <Animated filename="objects/vehicles/HMMWV/HMMWV.cga" filenameDestroyed="objects/vehicles/HMMWV/HMMWV_destroyed.cga" id="idModel"/>

    Replace the filename with your custom model.

    <Animated filename="objects/vehicles/Impala/Impala.cga" filenameDestroyed="objects/vehicles/Impala/Impala_destroyed.cga" id="idModel"/>
  2. At this point you should be able to test the vehicle in the editor.  Select the Entity menu from the RollupBar and select your vehicle from the Vehicle folder.
    RollupBar

    RollupBar

    Assuming everything worked you should be able to jump in to the game, walk up to the car and press F to enter.  The exact entry location of the vehicle may be a little off as it is still set for the HMMWV.

  3. The first thing that you will notice is that the character is floating in space.  This is because we haven’t set the drivers position yet.  The sitting position is defined by a dummy object in the .Max file.  Open your vehicle and add a new dummy object called passenger01_seat_pos.  This should be positioned slightly above the drivers seat.  While you have Max open, you may want to add dummy objects for the other seating positions and entry points etc.  For my car I was only interested in having a single seating position.  The dummy names aren’t important other than the .xml values must match the dummy name exactly.  Make sure that any dummy objects you have added are linked to the base dummy object and re-export.
  4. Now the player character should be sat in an appropriate position.  The next thing that we will deal with are the Lights and the Exhausts.  The process for setting each of these up is the same and is very simple. First add a new <Part> under the <Parts> tag.  The following example is for the Left Headlight.
    <Part name="headLightLeft" class="Light" component="headLightLeft" helper="headLightLeft">
     <Light type="HeadLightFlare" id="idHeadLightFlare1"/>
     </Part>

    The <Part> uses a <Helper> to set the position of the light.  This is set under the <Helpers> tag.

     <Helper name="headLightLeft" position="-0.65,2.3,0.55" direction="0,1,0" part="hull"/>

    The benefit of having this value in the .xml is that you can easily tweak it without having to re-export from the .max file.  Simply adjust the values until you get the desired result.  Take a look at the HMMWV.xml for more examples of the different <Light> properties and how to set up the exhausts.  If you want to use different particle effects for the exhausts look for the <Particles> tag at the bottom of the .xml file.

  5. Finally you will want to take a look at the properties for the wheels.  These can be found under the <Parts> tag.  
    <SubPartWheel axle="0" density="0" damping="-0.7" driving="1" lenMax="0.3" maxFriction="1" minFriction="1" stiffness="0" suspLength="0.25"/>

    Try different values for the stiffness, friction etc, as they can dramatically change how the vehicle drives.

  6. Study the HMMWV.xml to see how the rest of the tags are used.  Once you have the basics down, everything else is easy to modify.
This entry was posted in 3D Models, CryEngine and tagged , , , , , . Bookmark the permalink.

2 Responses to Creating A Custom Car in CryEngine 3 Part Two: Creating the Vehicle Definition in CryEngine

  1. Tao Pik says:

    I keep looking for a setup to open/close door of a vehicle throughout internet. no luck so far.

    • bennash1982 says:

      I’m not sure about this. I think it might require some custom code. I’ve never tried it myself. Study the setup of the example vehicles. I guess the doors would have to be separate to the main mesh, with the pivot point at the front so the door would open correctly. Is there a door type in the vehicle editor?

      Sorry I couldn’t be more help. Very busy at the moment.

Leave a comment