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 SoulGames > Utilities > Scripts. It is attached to the WASD Camera Controller Prefab, located in: SoulGames > Easy Grid Builder Pro 2 > Prefabs > Sample Camera Controller.

Camera Settings

Property
Function
Required

Camera Transform

The camera's transform component

Yes

Normal Speed

Camera movement speed during normal operation

No

Fast Speed

Camera movement speed when the speed-up key is held

No

Movement Lerp Time

The smoothing time for camera movement transitions

No

Rotation Settings

Property
Function
Required

Rotation Amount

The angle by which the camera rotates per input

No

Rotation Lerp Time

The smoothing time for rotation transitions

No

Zoom Settings

Property
Function
Required

Zoom Amount

The amount of zoom applied per input

No

Min Zoom

The closest zoom level allowed

No

Max Zoom

The farthest zoom level allowed

No

Zoom Lerp Time

The smoothing time for zoom transitions

No

Height Adjustment

Property
Function
Required

Set Height by Raycast

Enables automatic camera height adjustment using raycasting to detect ground or terrain

No

Raycast Layer Mask

Specifies the layers to include in raycasting for height adjustment

No

Input Keys

Property
Function
Required

Up Key

Key to move the camera forward

No

Down Key

Key to move the camera backward

No

Left Key

Key to move the camera left

No

Right Key

Key to move the camera right

No

Speed Up Key

Key to increase the camera movement speed temporarily

No

Rotate Left Key

Key to rotate the camera left

No

Rotate Right Key

Key to rotate the camera right

No

Zoom In Key

Key to zoom in the camera

No

Zoom Out Key

Key to zoom out the camera

No


Example Use case

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.

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

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

Last updated