Defining a sitting location

Up to this point, we haven't addressed the issue of the player hanging out of the side of the vehicle every time the they enter it. This is due to the fact that there is no sitting position defined for the driver position and thus leaves the player in the last position and pose before entering the vehicle. In this recipe, we will fix this problem by creating a new helper within the vehicle XML.

Getting ready

Complete the Creating a new car XML recipe. Then open MyVehicle.xml in Notepad or an equivalent editor.

How to do it...

  1. Between the <Parts> and <Seats> cells, you will need to insert the following lines into the car XML:
    <Helpers>
    <Helper name="driver_sit_pos" position="-0.75,0.25,1.5"direction="0,1,0" part="body"/>
    </Helpers>
    
  2. After writing in the Helpers cell, we now need to define on the driver seat which helper the player needs to take in order to be positioned in that seat.
  3. For the <Seat name="driver"> cell, you will need to change the following property:
    sitHelper=""
    
  4. Change this value to:
    sitHelper="driver_sit_pos"
    
  5. Save the XML and reload the car in the level.

How it works...

This simple seat helper lets the vehicle code know where the passengers of that particular seat need to be positioned in the vehicle. Be aware that this only aligns the root pivot of the character to this position. So in order to pose a character to sit in this position, it is a good practice to create a new animation graph and animation that moves the character so that the root pivot aligns to a bone on the character such as the pelvis.

There's more...

You can use the HMMWV animation graph to give a seated position to your character. If no changes to the player model have been made to the skeleton, then we will be able to utilize the animation graph from the SDK's HMMWV to pose our character. Within the same <Seat name="driver"> cell, add the following property:

agVehicleName="HMMWV"

This will use the animation graph to play the same animations used for entering and exiting the vehicle as well as utilizing the same sitting pose as the one used for the HMMWV.

There's more...

See also

  • Creating a new car XML
  • Setting up multiple cameras for the car
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.138.195