Joskaia ebla v jopu

This commit is contained in:
DedMoroz132
2022-04-18 17:54:37 +07:00
parent bbadfc5c26
commit 6b9c559a69
32 changed files with 45892 additions and 1163 deletions

View File

@ -53,11 +53,13 @@ public class scr_CharacterController : MonoBehaviour
[HideInInspector]
public bool isSprinting;
public bool isWalking;
private Vector3 newMovementSpeed;
private Vector3 newMovementSpeedVelocity;
[Header("Weapon")]
//[Header("Weapon")]
[HideInInspector]
public scr_WeaponController currentWeapon;
public float weaponAnimationSpeed;
@ -89,11 +91,11 @@ public class scr_CharacterController : MonoBehaviour
characterController = GetComponent<CharacterController>();
cameraHeight = cameraHolder.localPosition.y;
/*
if (currentWeapon)
{
currentWeapon.Initialise(this);
}
}*/
}
@ -141,11 +143,14 @@ public class scr_CharacterController : MonoBehaviour
private void CalculateMovement()
{
if (input_Movement.y <= 0.2f)
if (input_Movement.y <= 0.3f)
{
isSprinting = false;
}
if (input_Movement.y <= 0.2f)
{
isWalking = false;
}
var verticalSpeed = playerSettings.WalkingForwardSpeed;
var horizontalSpeed = playerSettings.WalkingStrafeSpeed;

View File

@ -0,0 +1,81 @@
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
using static scr_Models;
public class scr_FullCharacterController : MonoBehaviour
{
private scr_CharacterController characterController;
[Header("Settings")]
public WeaponSettingsModel settings;
[Header("References")]
public Animator SciFiWarriorOur;
private bool isInitialised;
Vector3 newWeaponRotation;
Vector3 newWeaponRotationVelocity;
Vector3 targetWeaponRotation;
Vector3 targetWeaponRotationVelocity;
Vector3 newWeaponMovementRotation;
Vector3 newWeaponRotationMovementVelocity;
Vector3 targetWeaponMovementRotation;
Vector3 targetWeaponMovementRotationVelocity;
private void Start()
{
newWeaponRotation = transform.localRotation.eulerAngles;
}
public void Initialise(scr_CharacterController CharacterController)
{
characterController = CharacterController;
isInitialised = true;
}
public void Update()
{
if (!isInitialised)
{
return;
}
CalculateWeaponRotation();
SetWeaponAnimation();
}
private void CalculateWeaponRotation()
{
SciFiWarriorOur.speed = characterController.weaponAnimationSpeed;
targetWeaponRotation.y += settings.SwayAmount * (settings.SwayXInverted ? -characterController.input_View.x : characterController.input_View.x) * Time.deltaTime;
targetWeaponRotation.x += settings.SwayAmount * (settings.SwayYInverted ? characterController.input_View.y : -characterController.input_View.y) * Time.deltaTime;
//newWeaponRotation.x = Mathf.Clamp(newWeaponRotation.x, ViewClampYMin, ViewClampYMax);
targetWeaponRotation.x = Mathf.Clamp(targetWeaponRotation.x, -settings.SwayClampX, settings.SwayClampX);
targetWeaponRotation.y = Mathf.Clamp(targetWeaponRotation.y, -settings.SwayClampY, settings.SwayClampY);
targetWeaponRotation.z = targetWeaponRotation.y;
targetWeaponRotation = Vector3.SmoothDamp(targetWeaponRotation, Vector3.zero, ref targetWeaponRotationVelocity, settings.SwayResetSmoothing);
newWeaponRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
targetWeaponMovementRotation.z = settings.MovementSwayX * (settings.MovementSwayXInverted ? -characterController.input_Movement.x : characterController.input_Movement.x);
targetWeaponMovementRotation.x = settings.MovementSwayY * (settings.MovementSwayYInverted ? -characterController.input_Movement.y : characterController.input_Movement.y);
targetWeaponMovementRotation = Vector3.SmoothDamp(targetWeaponMovementRotation, Vector3.zero, ref targetWeaponMovementRotationVelocity, settings.SwayResetSmoothing);
newWeaponMovementRotation = Vector3.SmoothDamp(newWeaponRotation, targetWeaponMovementRotation, ref newWeaponRotationVelocity, settings.SwaySmoothing);
transform.localRotation = Quaternion.Euler(newWeaponRotation);
}
private void SetWeaponAnimation()
{
SciFiWarriorOur.SetBool("isSprinting", characterController.isSprinting);
SciFiWarriorOur.SetBool("isWalking", characterController.isWalking);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d42553a14d6745f9ab94d91cc5e1850a
timeCreated: 1650274114