ооооо

This commit is contained in:
Enikeevtimur
2022-04-18 22:37:09 +07:00
parent d911dce62a
commit dfbdf7ad31
1505 changed files with 696529 additions and 513 deletions

View File

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using Unity.Barracuda;
using UnityEngine;
using UnityEngine.InputSystem;
using static scr_Models;
@ -11,7 +12,9 @@ public class scr_CharacterController : MonoBehaviour
private CharacterController characterController;
private DefaultInput defaultInput;
private Vector2 input_Movement;
[HideInInspector]
public Vector2 input_Movement;
[HideInInspector]
public Vector2 input_View;
@ -48,12 +51,25 @@ public class scr_CharacterController : MonoBehaviour
private float cameraHeight;
private float cameraHeightVelocity;
private bool isSprinting;
[HideInInspector]
public bool isSprinting;
public bool isWalking;
private Vector3 newMovementSpeed;
private Vector3 newMovementSpeedVelocity;
[Header("Weapon")] public scr_WeaponController currentWeapon;
//[Header("Weapon")]
[HideInInspector]
public scr_WeaponController currentWeapon;
public float weaponAnimationSpeed;
public float damage = 10f;
public float range = 100f;
public Camera fpsCam;
public ParticleSystem muzzleFlash;
public GameObject impactEffect;
private void Awake()
{
defaultInput = new DefaultInput();
@ -75,22 +91,45 @@ public class scr_CharacterController : MonoBehaviour
characterController = GetComponent<CharacterController>();
cameraHeight = cameraHolder.localPosition.y;
/*
if (currentWeapon)
{
currentWeapon.Initialise(this);
}
}*/
}
private void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Shoot();
}
CalculateView();
CalculateMovement();
CalculateJump();
CalculateCameraHeight();
}
void Shoot()
{
muzzleFlash.Play();
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
Target target = hit.transform.GetComponent<Target>();
if (target != null)
{
target.TakeDamage(damage);
}
Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
}
}
private void CalculateView()
{
newCharacterRotation.y += playerSettings.ViewXSensetivity * (playerSettings.ViewXInverted ? -input_View.x : input_View.x) * Time.deltaTime;
@ -104,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;
@ -119,6 +161,7 @@ public class scr_CharacterController : MonoBehaviour
}
// Effectors
if (!characterController.isGrounded)
{
playerSettings.SpeedEffector = playerSettings.FallingSpeedEffector;
@ -136,6 +179,13 @@ public class scr_CharacterController : MonoBehaviour
playerSettings.SpeedEffector = 1;
}
weaponAnimationSpeed = characterController.velocity.magnitude / (playerSettings.WalkingForwardSpeed * playerSettings.SpeedEffector);
if (weaponAnimationSpeed > 1)
{
weaponAnimationSpeed = 1;
}
verticalSpeed *= playerSettings.SpeedEffector;
horizontalSpeed *= playerSettings.SpeedEffector;

View File

@ -61,7 +61,7 @@ public static class scr_Models
[Serializable]
public class WeaponSettingsModel
{
[Header("Sway")]
[Header("Weapon Sway")]
public float SwayAmount;
public bool SwayYInverted;
public bool SwayXInverted;
@ -69,6 +69,13 @@ public static class scr_Models
public float SwayResetSmoothing;
public float SwayClampX;
public float SwayClampY;
[Header("Weapon Movement Sway")]
public float MovementSwayX;
public float MovementSwayY;
public bool MovementSwayYInverted;
public bool MovementSwayXInverted;
public float MovementSwaySmoothing;
}
#endregion