# WASD Camera Controller

The **WASD Camera Controller** component allows for smooth and responsive camera control using keyboard inputs. It supports movement, rotation, and zoom functionality, as well as optional height adjustment using raycasting to follow terrain or other surfaces dynamically.

You can find this component in <mark style="color:purple;">**SoulGames > Utilities > Scripts**</mark><mark style="color:purple;">.</mark> It is attached to the **WASD Camera Controller Prefab**, located in: <mark style="color:purple;">**SoulGames > Easy Grid Builder Pro 2 > Prefabs > Sample Camera Controller**</mark><mark style="color:purple;">.</mark>

<figure><img src="https://2651556506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeumhICLT4oHoEIEssOjB%2Fuploads%2FkVuMzAcc5ePCRrX2VIXU%2Fimage.png?alt=media&#x26;token=54ab27b9-dc4a-4ff4-b9e2-b6d50a3b571f" alt=""><figcaption></figcaption></figure>

### <mark style="color:orange;">Camera Settings</mark>

<table data-full-width="false"><thead><tr><th width="216">Property</th><th width="429.3333333333333">Function</th><th>Required</th></tr></thead><tbody><tr><td>Camera Transform</td><td>The camera's transform component</td><td><mark style="color:red;">Yes</mark></td></tr><tr><td>Normal Speed</td><td>Camera movement speed during normal operation</td><td>No</td></tr><tr><td>Fast Speed</td><td>Camera movement speed when the speed-up key is held</td><td>No</td></tr><tr><td>Movement Lerp Time</td><td>The smoothing time for camera movement transitions</td><td>No</td></tr></tbody></table>

### <mark style="color:orange;">Rotation Settings</mark>

<table data-full-width="false"><thead><tr><th width="216">Property</th><th width="429.3333333333333">Function</th><th>Required</th></tr></thead><tbody><tr><td>Rotation Amount</td><td>The angle by which the camera rotates per input</td><td>No</td></tr><tr><td>Rotation Lerp Time</td><td>The smoothing time for rotation transitions</td><td>No</td></tr></tbody></table>

### <mark style="color:orange;">Zoom Settings</mark>

<table data-full-width="false"><thead><tr><th width="216">Property</th><th width="429.3333333333333">Function</th><th>Required</th></tr></thead><tbody><tr><td>Zoom Amount</td><td>The amount of zoom applied per input</td><td>No</td></tr><tr><td>Min Zoom</td><td>The closest zoom level allowed</td><td>No</td></tr><tr><td>Max Zoom</td><td>The farthest zoom level allowed</td><td>No</td></tr><tr><td>Zoom Lerp Time</td><td>The smoothing time for zoom transitions</td><td>No</td></tr></tbody></table>

### <mark style="color:orange;">Height Adjustment</mark>

<table data-full-width="false"><thead><tr><th width="216">Property</th><th width="429.3333333333333">Function</th><th>Required</th></tr></thead><tbody><tr><td>Set Height by Raycast</td><td>Enables automatic camera height adjustment using raycasting to detect ground or terrain</td><td>No</td></tr><tr><td>Raycast Layer Mask</td><td>Specifies the layers to include in raycasting for height adjustment</td><td>No</td></tr></tbody></table>

### <mark style="color:orange;">Input Keys</mark>

<table data-full-width="false"><thead><tr><th width="216">Property</th><th width="429.3333333333333">Function</th><th>Required</th></tr></thead><tbody><tr><td>Up Key</td><td>Key to move the camera forward</td><td>No</td></tr><tr><td>Down Key</td><td>Key to move the camera backward</td><td>No</td></tr><tr><td>Left Key</td><td>Key to move the camera left</td><td>No</td></tr><tr><td>Right Key</td><td>Key to move the camera right</td><td>No</td></tr><tr><td>Speed Up Key</td><td>Key to increase the camera movement speed temporarily</td><td>No</td></tr><tr><td>Rotate Left Key</td><td>Key to rotate the camera left</td><td>No</td></tr><tr><td>Rotate Right Key</td><td>Key to rotate the camera right</td><td>No</td></tr><tr><td>Zoom In Key</td><td>Key to zoom in the camera</td><td>No</td></tr><tr><td>Zoom Out Key</td><td>Key to zoom out the camera</td><td>No</td></tr></tbody></table>

***

## <mark style="color:green;">Example Use case</mark>

The **WASD Camera Controller** supports both 2D and 3D games, providing a dynamic and flexible camera controller powered by **Cinemachine**. To use the controller: Drag and drop the **WASD Camera Controller Prefab** into your scene and hit play.&#x20;

Modify the **WASDCameraCMV** GameObject's Transform values inside the **WASD Camera Controller Prefab** to set the default starting position and rotation for the camera.&#x20;

If you encounter unwanted zoom behavior, set all values under the **Zoom Settings** to **0** to resolve the issue.

<figure><img src="https://2651556506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeumhICLT4oHoEIEssOjB%2Fuploads%2FvHcQ6vlPFy4R3gChlAB6%2Fimage.png?alt=media&#x26;token=ceec4af3-d8c6-49ef-8545-4bcb236e799a" alt=""><figcaption></figcaption></figure>
