# How to enter and exit from a vehicle

Any vehicle can be controlled by the player, basically the entry system will disable the character controls and enable the vehicle control.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FHjuEI98PUGP4h3j7Euut%2Fdriving%20vehicle.gif?alt=media&#x26;token=cde7940e-ef3d-4eb1-9e42-6355244a90c3" alt=""><figcaption></figcaption></figure>

To drive a `Vehicle` the character must have the `Drive Vehicle System`

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FQ8J35NRbVimB6HffzGsa%2Fdrive%20vehicles%20component.png?alt=media&#x26;token=2d89e91d-5b1a-49a2-a4ff-3b597dee7ef0" alt=""><figcaption></figcaption></figure>

| Property                   | Description                                                                                                            |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| Start Vehicle              | A default vehicle to start driving                                                                                     |
| Enter Vehicles Enabled     | If true, the character can enter and drive vehicles.                                                                   |
| Exit Vehicles Enabled      | If true, the character can exit from the `Vehicle` if is driving.                                                      |
| Disable Character On Enter | Disable the character after enter on the vehicle, usefull for vehicles that not have IK settings for drive animations. |
| Delay To Re enable Action  | The time to reactive enter vehicle action after start enter or exit of some `Vehicle`. Can't be less than 0.1.         |
| Max Vehicle Speed To Exit  | Don't allow to exit from a vehicle on high speeds.                                                                     |
| Ground Layer               | The layer used to detect the ground to set the character position when exit from the current vehicle.                  |

## How vehicle detection works ?

Vehicles must have a child trigger with a specific tag and layer, the trigger must have a JU Vehicle Interactable to work.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2F12VvSudzofKBkpRCn1TP%2Fimage.png?alt=media&#x26;token=94d05a46-b88f-4d48-aa2d-8625a49fcd2d" alt=""><figcaption></figcaption></figure>

The Player needs to have a [JU Interaction System](https://julhiecio.gitbook.io/ju-tps-documentation/game-development/new-interaction-system), which will detect the vehicle's trigger.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FlD63nVaN5pkeXEFZAbUd%2Fimage.png?alt=media&#x26;token=275ecac3-b66e-48c7-b745-ba65f34ee6d0" alt=""><figcaption></figcaption></figure>

## Characters without driver animations

For simple games you can disable the character instead of use complex animations and IK system.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FFiiuy1ljAIcL5fwAhbhT%2Fdisable%20character.png?alt=media&#x26;token=e6cc9623-3f46-4a4a-b13f-0576d4aee598" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FE9VBokYOgbsWVo8bH3wj%2Fdisabled%20character%20driver.gif?alt=media&#x26;token=fae9cbea-6760-4bf6-9cde-b229841e51ef" alt=""><figcaption></figcaption></figure>

## Simple Character Driver Animation

If you have a character animation that match with the vehicle model you can use the `JUVehicleCharacterIK` to set the character position inside the vehicle.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FVJN58XU6YFyT6u9Gshxl%2FConfigure%20simple%20character%20driver%20anim.png?alt=media&#x26;token=834a2a5b-442e-4868-b382-0b29bb19f3f8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FTDBcbBeLYCgIQ5UzFPu8%2Fdrive%20simple%20animation.gif?alt=media&#x26;token=c2907fbe-7a92-4bc8-b0c6-7a94905c6b79" alt=""><figcaption></figcaption></figure>

## Advanced Character Driver Animations with IK

You can use foot and hand IK on vehicles if you want, very useful to make wheel steer, motorcycle inclination animation or foot placements.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2Fvs50pYxGb6WyufsfbEam%2Fdrive%20vehicle%20ik.gif?alt=media&#x26;token=b67f3f1e-25bc-4d3b-ad9a-3157abb6dc99" alt=""><figcaption></figcaption></figure>

To use it, the character must have the `DriverProceduralAnimation` component, it's is responsible by the IK system.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FjFm1dsWiXrF1H0cEyHcg%2Fcharacter%20procedural%20animation%20component.png?alt=media&#x26;token=57ae6271-888f-4df4-9268-99ba0b0894b0" alt=""><figcaption></figcaption></figure>

Furthermore, you need to have assigned all the IK target positions on the `JUVehicleCharacterIK` of the vehicle and the IK weights configured.

<figure><img src="https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FIWJuncKR6lrQ4YXM5OYa%2Fdriver%20ik%20settings.png?alt=media&#x26;token=abb62057-e24f-43c0-98e8-67d6ffd2dd5a" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Tip: if you see a prefab of a vehicle you will notice hand, foot, sphere or humanoid character gizmos. You can copy these GameObjects, paste them into your new vehicle, position them and assign them to the above parameters.

![](https://2945806600-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCQMDx0LmgnRXXTklLhoh%2Fuploads%2FLnoiJ8GLLRwnvMEvaUo3%2Fimage.png?alt=media\&token=51ad8ec6-3a58-495e-9d34-14ccb99f859f)
{% endhint %}

## Standard IK Settings

| Inverse Kinematics Target Positions | Description                                 |
| ----------------------------------- | ------------------------------------------- |
| Character Location                  | Character body position in vehicle          |
| Left Hand Position IK               | Left hand position and rotation in vehicle  |
| Right Hand Position IK              | Right hand position and rotation in vehicle |
| Left Foot Position IK               | Left foot position and rotation in vehicle  |
| Right Foot Position IK              | Right foot position and rotation in vehicle |

| IK Animation Weights Parameters | Description                                                |
| ------------------------------- | ---------------------------------------------------------- |
| Frontal Lean Weight             | Frontal Lean Motion Weight IK                              |
| Side Lean Weight                | Side lean Motion Weight IK                                 |
| Look At Direction Weight        | Look At Motion Weight IK                                   |
| Hint Movement Weight            | Hint Motion Weight IK                                      |
| Foot Placement                  | Foot placement in driving (Motorcycle or Bike for example) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julhiecio.gitbook.io/ju-tps-documentation/game-development/how-to-use-vehicle-system/how-to-enter-and-exit-from-a-vehicle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
