Cameras - NeisesMike/VehicleFramework GitHub Wiki
A vehicle pilot can rotate through their vehicle's cameras.
The default keys for this are T and F and V, but you can change that in the mod options menu.
Overview
ModVehicle has the field:
public virtual List<VehicleParts.VehicleCamera> Cameras => new List<VehicleParts.VehicleCamera>();
This is the definition of the VehicleCamera struct.
public struct VehicleCamera
{
public string name;
public Transform camera;
public VehicleCamera(Transform cameraTransform, string cameraName)
{
name = cameraName;
camera = cameraTransform;
}
}
The Transform camera will be where the camera is placed. Make sure that z-positive (the blue arrow) points the direction you want the camera to face. Remember that y-positive (yellow-green arrow) is UP.
The string name doesn't really matter except that it must be unique. You can't have two cameras with the same name, or else the camera-toggling mechanics won't work the way you expect.
Example
The Odyssey implements its cameras like this. First the Odyssey class has these two private fields, for ease of use:
private Transform topCam => transform.Find("Geometry/camera/lens");
private Transform bottomCam => transform.Find("Geometry/camera2/lens");
Then all I have to do is override Cameras like this:
public override List<VehicleCamera> Cameras => new List<VehicleCamera>
{
new VehicleCamera(topCam, "top"),
new VehicleCamera(bottomCam, "bottom")
};
That's it.