Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Cinemachine;
- using UnityEngine;
- using UnityEngine.InputSystem;
- public class ChangeSensOnInput : PlayerCameras
- {
- //Mouse and Keyboard
- //FreeLook M&K values Spark
- private float xSensibilityFreeLookMandKSpark = 120f;
- private float ySensibilityFreeLookMandKSpark = 0.7f;
- //Aim M&K values Spark
- private float xSensibilityAimMandKSpark = 120f;
- private float ySensibilityAimMandKSpark = 0.7f;
- //FreeLook M&K values Kling
- private float xSensibilityFreeLookMandKKling = 150f;
- private float ySensibilityFreeLookMandKKling = 0.9f;
- //Aim M&K values Kling
- private float xSensibilityAimMandKKling = 80f;
- private float ySensibilityAimMandKKling = 0.3f;
- //Gamepad
- //FreeLook pad values Spark
- private float xSensibilityFreeLookGamepadSpark = 220f;
- private float ySensibilityFreeLookGamepadSpark = 1f;
- //Aim pad values Spark
- private float xSensibilityAimGamepadSpark = 60f;
- private float ySensibilityAimGamepadSpark = 0.25f;
- //FreeLook pad values Kling
- private float xSensibilityFreeLookGamepadKling = 200f;
- private float ySensibilityFreeLookGamepadKling = 1f;
- //Aim pad values Kling
- private float xSensibilityAimGamepadKling = 70f;
- private float ySensibilityAimGamepadKling = 0.5f;
- private PlayerInput klingInput;
- private PlayerInput sparkInput;
- private protected override void Awake()
- {
- //Get player input of Spark
- sparkInput = getPlayerInput(Spark);
- //Get player input of Kling
- klingInput = getPlayerInput(Kling);
- }
- private PlayerInput getPlayerInput(GameObject character)
- {
- Transform InputTransform = character.transform.Find("Smooth Player Controller");
- return InputTransform.GetComponent<PlayerInput>();
- }
- public void ChangeSensitivityBasedOnControlScheme()
- {
- SetCameraSensitivityKling(klingInput.currentControlScheme == "Gamepad");
- SetCameraSensitivitySpark(sparkInput.currentControlScheme == "Gamepad");
- }
- private void SetCameraSensitivitySpark(bool gamepad)
- {
- if (gamepad)
- {
- //Set Spark Gamepad FreeLook values
- FreeLookSpark.m_XAxis.m_MaxSpeed = xSensibilityFreeLookGamepadSpark;
- FreeLookSpark.m_YAxis.m_MaxSpeed = ySensibilityFreeLookGamepadSpark;
- //Set Spark Gamepad Aim values
- AimSpark.m_XAxis.m_MaxSpeed = xSensibilityAimGamepadSpark;
- AimSpark.m_YAxis.m_MaxSpeed = ySensibilityAimGamepadSpark;
- }
- else
- {
- //Set Spark M&K FreeLook values
- FreeLookSpark.m_XAxis.m_MaxSpeed = xSensibilityFreeLookMandKSpark;
- FreeLookSpark.m_YAxis.m_MaxSpeed = ySensibilityFreeLookMandKSpark;
- //Set Spark M&K Aim values
- AimSpark.m_XAxis.m_MaxSpeed = xSensibilityAimMandKSpark;
- AimSpark.m_YAxis.m_MaxSpeed = ySensibilityAimMandKSpark;
- }
- }
- private void SetCameraSensitivityKling(bool gamepad)
- {
- if (gamepad)
- {
- //Set Kling Gamepad FreeLook values
- FreeLookKling.m_XAxis.m_MaxSpeed = xSensibilityFreeLookGamepadKling;
- FreeLookKling.m_YAxis.m_MaxSpeed = ySensibilityFreeLookGamepadKling;
- //Set Kling Gamepad Aim values
- AimKling.m_XAxis.m_MaxSpeed = xSensibilityAimGamepadKling;
- AimKling.m_YAxis.m_MaxSpeed = ySensibilityAimGamepadKling;
- }
- else
- {
- //Set Kling M&K FreeLook values
- FreeLookKling.m_XAxis.m_MaxSpeed = xSensibilityFreeLookMandKKling;
- FreeLookKling.m_YAxis.m_MaxSpeed = ySensibilityFreeLookMandKKling;
- //Set Kling M&K Aim values
- AimKling.m_XAxis.m_MaxSpeed = xSensibilityAimMandKKling;
- AimKling.m_YAxis.m_MaxSpeed = ySensibilityAimMandKKling;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement