wip: add aim
This commit is contained in:
@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Barracuda;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
using static scr_Models;
|
||||
|
||||
@ -11,6 +12,7 @@ public class scr_CharacterController : MonoBehaviour
|
||||
|
||||
private CharacterController characterController;
|
||||
private DefaultInput defaultInput;
|
||||
|
||||
[HideInInspector]
|
||||
public Vector2 input_Movement;
|
||||
[HideInInspector]
|
||||
@ -59,6 +61,11 @@ public class scr_CharacterController : MonoBehaviour
|
||||
public scr_WeaponController currentWeapon;
|
||||
|
||||
public float weaponAnimationSpeed;
|
||||
|
||||
public float damage = 10f;
|
||||
public float range = 100f;
|
||||
|
||||
public Camera fpsCam;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -86,17 +93,31 @@ public class scr_CharacterController : MonoBehaviour
|
||||
{
|
||||
currentWeapon.Initialise(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetButtonDown("Fire1"))
|
||||
{
|
||||
Shoot();
|
||||
}
|
||||
CalculateView();
|
||||
CalculateMovement();
|
||||
CalculateJump();
|
||||
CalculateCameraHeight();
|
||||
}
|
||||
|
||||
void Shoot()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
|
||||
{
|
||||
Debug.Log(hit.transform.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CalculateView()
|
||||
{
|
||||
newCharacterRotation.y += playerSettings.ViewXSensetivity * (playerSettings.ViewXInverted ? -input_View.x : input_View.x) * Time.deltaTime;
|
||||
|
@ -1,29 +1,31 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using static scr_Models;
|
||||
|
||||
public class scr_WeaponController : MonoBehaviour
|
||||
{
|
||||
private scr_CharacterController characterController;
|
||||
[Header("Settings")]
|
||||
[Header("Settings")]
|
||||
public WeaponSettingsModel settings;
|
||||
|
||||
|
||||
[Header("References")]
|
||||
|
||||
public Animator weaponAnimator;
|
||||
|
||||
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;
|
||||
@ -45,7 +47,6 @@ public class scr_WeaponController : MonoBehaviour
|
||||
CalculateWeaponRotation();
|
||||
SetWeaponAnimation();
|
||||
}
|
||||
|
||||
private void CalculateWeaponRotation()
|
||||
{
|
||||
weaponAnimator.speed = characterController.weaponAnimationSpeed;
|
||||
|
Reference in New Issue
Block a user