Posted December 11, 2023 by Max Keeley
Welcome to the Devlog! Here you can find the basics of player movement, camera setup, object interactions and more. Download the Developer Scripts and reference the instructions below to start creating!
// Camera Setup //
Out of the box, I implemented a basic first-person camera setup consisting of a Main gameplay camera and nested secondary camera that uses occlusion culling and empty game objects with reference points; one point for picking up items and reorienting them, one for the spawn point/angle of projectiles (shooting script), and the last, a parent for an unfiltered player POV. All mouse based movements follow the child nested scripts for the First Person Player as shown below.
For cross-platform VR/XR development, confirm that your script and player build input settings have the same values applied. Enable ‘Virtual Reality Support’ in Project Settings > Player and add your desired hardware support SDK via XR Plugin Management package. The basic axis based movements are applied as follows:
void Update()
{
//move mouse left and right
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
internal static float verticalSensitivity;
internal static float lateralSensitivity;
}
The diagram below details the duel camera setup for the default implemented settings. By default the movement script applied to the player object runs constant raycast groundchecks against the predefined layer ‘Ground’ overriding the need to make all ground objects a rigid body with mesh vertex collider.
// Player Setup //
Edit the variables of the included Character Controller to to fit your gameplay style. Out of the box it supplies movement speed, jump, sprint, and gravity. Note that by default, the same environmental gravity is applied to all gameplay objects in the sandbox. Make sure that the variables are the same in the script editor as they are in the Unity inspector settings.
// VR Support in Unity //
This sandbox was created for use in desktop development and VR adaptive integration. Enable Virtual Reality support in Project Settings > Player and add your desired hardware support SDK via XR Plugin Management package. More on VR development in Unity at https://docs.unity3d.com/Manual/VROverview.html
Please reach out for any questions, comments or feedback at https://www.maxkeeley.com.
Thanks for viewing my game!