Commit 5e2c337e authored by Giannis Kepas's avatar Giannis Kepas
Browse files

better camera control

parent 422c67fb
Loading
Loading
Loading
Loading
+43 −8
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ RenderSettings:
  m_ReflectionBounces: 1
  m_ReflectionIntensity: 1
  m_CustomReflection: {fileID: 0}
  m_Sun: {fileID: 0}
  m_Sun: {fileID: 410087040}
  m_IndirectSpecularColor: {r: 0.17276844, g: 0.21589246, b: 0.2978263, a: 1}
  m_UseRadianceAmbientProbe: 0
--- !u!157 &3
@@ -104,7 +104,7 @@ NavMeshSettings:
  serializedVersion: 2
  m_ObjectHideFlags: 0
  m_BuildSettings:
    serializedVersion: 2
    serializedVersion: 3
    agentTypeID: 0
    agentRadius: 0.5
    agentHeight: 2
@@ -117,7 +117,7 @@ NavMeshSettings:
    cellSize: 0.16666667
    manualTileSize: 0
    tileSize: 256
    accuratePlacement: 0
    buildHeightMesh: 0
    maxJobWorkers: 0
    preserveTilesOutsideBounds: 0
    debug:
@@ -161,13 +161,21 @@ Camera:
  m_Enabled: 1
  serializedVersion: 2
  m_ClearFlags: 1
  m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
  m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
  m_projectionMatrixMode: 1
  m_GateFitMode: 2
  m_FOVAxisMode: 0
  m_Iso: 200
  m_ShutterSpeed: 0.005
  m_Aperture: 16
  m_FocusDistance: 10
  m_FocalLength: 50
  m_BladeCount: 5
  m_Curvature: {x: 2, y: 11}
  m_BarrelClipping: 0.25
  m_Anamorphism: 0
  m_SensorSize: {x: 36, y: 24}
  m_LensShift: {x: 0, y: 0}
  m_FocalLength: 50
  m_NormalizedViewPortRect:
    serializedVersion: 2
    x: 0
@@ -201,13 +209,13 @@ Transform:
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 330585543}
  serializedVersion: 2
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 0.5, z: 0}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children: []
  m_Father: {fileID: 0}
  m_RootOrder: 3
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &330585547
MonoBehaviour:
@@ -239,9 +247,20 @@ MonoBehaviour:
  m_Dithering: 0
  m_ClearDepth: 1
  m_AllowXRRendering: 1
  m_AllowHDROutput: 1
  m_UseScreenCoordOverride: 0
  m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
  m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
  m_RequiresDepthTexture: 0
  m_RequiresColorTexture: 0
  m_Version: 2
  m_TaaSettings:
    quality: 3
    frameInfluence: 0.1
    jitterScale: 1
    mipBias: 0
    varianceClampScale: 0.9
    contrastAdaptiveSharpening: 0
--- !u!114 &330585548
MonoBehaviour:
  m_ObjectHideFlags: 0
@@ -255,6 +274,7 @@ MonoBehaviour:
  m_Name: 
  m_EditorClassIdentifier: 
  Speed: 1
  RunSpeed: 4
  Sensitivity: 2
--- !u!1 &410087039
GameObject:
@@ -343,13 +363,13 @@ Transform:
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 410087039}
  serializedVersion: 2
  m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
  m_LocalPosition: {x: 0, y: 6.11, z: 0}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children: []
  m_Father: {fileID: 0}
  m_RootOrder: 0
  m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!114 &410087042
MonoBehaviour:
@@ -367,15 +387,19 @@ MonoBehaviour:
  m_UsePipelineSettings: 1
  m_AdditionalLightsShadowResolutionTier: 2
  m_LightLayerMask: 1
  m_RenderingLayers: 1
  m_CustomShadowLayers: 0
  m_ShadowLayerMask: 1
  m_ShadowRenderingLayers: 1
  m_LightCookieSize: {x: 1, y: 1}
  m_LightCookieOffset: {x: 0, y: 0}
  m_SoftShadowQuality: 0
--- !u!1001 &648843909
PrefabInstance:
  m_ObjectHideFlags: 0
  serializedVersion: 2
  m_Modification:
    serializedVersion: 3
    m_TransformParent: {fileID: 0}
    m_Modifications:
    - target: {fileID: -8679921383154817045, guid: 18e4af528dc928247bf6679c68c75b93,
@@ -439,6 +463,9 @@ PrefabInstance:
      value: KozaniLobby
      objectReference: {fileID: 0}
    m_RemovedComponents: []
    m_RemovedGameObjects: []
    m_AddedGameObjects: []
    m_AddedComponents: []
  m_SourcePrefab: {fileID: 100100000, guid: 18e4af528dc928247bf6679c68c75b93, type: 3}
--- !u!1 &832575517
GameObject:
@@ -481,11 +508,19 @@ Transform:
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 832575517}
  serializedVersion: 2
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 0, z: 0}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_ConstrainProportionsScale: 0
  m_Children: []
  m_Father: {fileID: 0}
  m_RootOrder: 1
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
  m_ObjectHideFlags: 0
  m_Roots:
  - {fileID: 410087041}
  - {fileID: 832575519}
  - {fileID: 648843909}
  - {fileID: 330585546}
+29 −3
Original line number Diff line number Diff line
@@ -4,23 +4,49 @@ using UnityEngine;
public class CameraController : MonoBehaviour
{
    [SerializeField] private float Speed = 1.0f;
    [SerializeField] private float Sensitivity = 5.0f;
    [SerializeField] private float RunSpeed = 4.0f;
    [SerializeField] private float Sensitivity = 2.0f;

    private float SavedSpeed;

    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
        SavedSpeed = Speed;
    }

    private void Update()
    {
        // Move the camera forward, backward, left, and right
        // Show cursor on escape press.
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible = true;
        }

        // Hide cursor on left mouse button click.
        if (Input.GetMouseButtonDown(0))
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;
        }

        if (Input.GetKeyDown(KeyCode.F)) Screen.fullScreen = true;

        if (Cursor.visible) return;

        if (Input.GetKeyDown(KeyCode.LeftShift)) Speed = RunSpeed;

        // Move the camera forward, backward, left, and right.
        transform.position += Input.GetAxis("Vertical") * Speed * Time.deltaTime * transform.forward;
        transform.position += Input.GetAxis("Horizontal") * Speed * Time.deltaTime * transform.right;

        // Rotate the camera based on the mouse movement
        // Rotate the camera based on the mouse movement.
        float mouseX = Input.GetAxis("Mouse X");
        float mouseY = Input.GetAxis("Mouse Y");
        transform.eulerAngles += new Vector3(-mouseY * Sensitivity, mouseX * Sensitivity, 0);

        if (Input.GetKeyUp(KeyCode.LeftShift)) Speed = SavedSpeed;
    }
}
+5 −0
Original line number Diff line number Diff line
{
    "m_Dictionary": {
        "m_DictionaryValues": []
    }
}
 No newline at end of file