As before

This commit is contained in:
Programmer-DField 2021-03-01 18:03:57 +00:00
parent 169c2a4477
commit 40075087aa
4 changed files with 1523 additions and 488 deletions

View File

@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(CinemachineFreeLook))]
public class FreeLookAddOn : MonoBehaviour
{
[Range(0f, 10f)] public float LookSpeed = 1f;
public bool InvertY = false;
private CinemachineFreeLook _freeLookComponent;
public void Start()
{
_freeLookComponent = GetComponent<CinemachineFreeLook>();
}
// Update the look movement each time the event is trigger
public void OnLook(InputAction.CallbackContext context)
{
//Normalize the vector to have an uniform vector in whichever form it came from (I.E Gamepad, mouse, etc)
Vector2 lookMovement = context.ReadValue<Vector2>().normalized;
lookMovement.y = InvertY ? -lookMovement.y : lookMovement.y;
// This is because X axis is only contains between -180 and 180 instead of 0 and 1 like the Y axis
lookMovement.x = lookMovement.x * 180f;
//Ajust axis values using look speed and Time.deltaTime so the look doesn't go faster if there is more FPS
_freeLookComponent.m_XAxis.Value += lookMovement.x * LookSpeed * Time.deltaTime;
_freeLookComponent.m_YAxis.Value += lookMovement.y * LookSpeed * Time.deltaTime;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e2b06b1980697747a979f7637a7276c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff