fixed strafing, added shooting effects, created a new testing level, enlarged enemies, updated bullet firing system
This commit is contained in:
@ -5,6 +5,7 @@ using Cinemachine;
|
||||
|
||||
public class CameraShift : MonoBehaviour
|
||||
{
|
||||
public static CameraShift active;
|
||||
[SerializeField]
|
||||
private Camera childCam;
|
||||
[SerializeField]
|
||||
@ -44,6 +45,7 @@ public class CameraShift : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
active = this;
|
||||
if (isCenter)
|
||||
{
|
||||
targetOffset= Vector3.zero;
|
||||
|
28
Assets/Scripts/Player/PlayerAim.cs
Normal file
28
Assets/Scripts/Player/PlayerAim.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerAim : MonoBehaviour
|
||||
{
|
||||
public static PlayerAim active;
|
||||
public Vector3 targetPosition;
|
||||
private Camera cam;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
active = this;
|
||||
cam = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Ray r = new Ray(cam.transform.position,cam.transform.forward);
|
||||
RaycastHit hit;
|
||||
if(Physics.Raycast(r,out hit))
|
||||
{
|
||||
targetPosition = hit.point;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Player/PlayerAim.cs.meta
Normal file
11
Assets/Scripts/Player/PlayerAim.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d0634141320a06b4f94b506dbed94499
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -31,7 +31,28 @@ public class PlayerAnimationController : MonoBehaviour
|
||||
{
|
||||
animController.SetFloat(runningSpeedParameter, movement.magnitude);
|
||||
animController.SetBool(runningParameter,isMoving);
|
||||
//animController.SetFloat(sideStepSpeedParameter, movement.x);
|
||||
|
||||
if (this.movement.IsAiming)
|
||||
{
|
||||
|
||||
animController.SetFloat("StrafingSpeed", movement.x);
|
||||
float dir = 0;
|
||||
if (movement.x > 0)
|
||||
{
|
||||
dir = 1;
|
||||
}else if (movement.x < 0)
|
||||
{
|
||||
dir = -1;
|
||||
}
|
||||
animController.SetFloat("StrafingDirection", dir);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
animController.SetFloat("StrafingSpeed", 0);
|
||||
animController.SetFloat("StrafingDirection", 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void Animate(PlayerQuickAnimationType animation)
|
||||
@ -64,7 +85,7 @@ public class PlayerAnimationController : MonoBehaviour
|
||||
{
|
||||
animController.SetBool("IsCarrying", interactionHandler.IsCarrying);
|
||||
animController.SetBool("HasGun",interactionHandler.GunEnabled);
|
||||
|
||||
|
||||
if (interactionHandler.GunEnabled&&!interactionHandler.isDead&&movement.AllowRotation)
|
||||
{
|
||||
|
||||
|
@ -249,7 +249,16 @@ public class PlayerInteractionHandler : MonoBehaviour
|
||||
this.DisableFlashlight();
|
||||
|
||||
float aimAxis = Input.GetAxis("Aim");
|
||||
|
||||
|
||||
if (aimAxis > 0.5f)
|
||||
{
|
||||
pistol.aimMode = PistolComponent.AimMode.CAMERA;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pistol.aimMode = PistolComponent.AimMode.MODIFIED;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -34,6 +34,8 @@ public class PlayerMovementController : MonoBehaviour
|
||||
|
||||
[HideInInspector]
|
||||
public bool AllowRotation = false;
|
||||
[HideInInspector]
|
||||
public bool IsAiming = false;
|
||||
|
||||
[SerializeField]
|
||||
private NoiseVisibilitySettingsManager noiseSettings;
|
||||
@ -80,9 +82,15 @@ public class PlayerMovementController : MonoBehaviour
|
||||
movement += cam.transform.forward *y * Time.deltaTime * speed;
|
||||
|
||||
//movement += transform.forward * Mathf.Abs(x) * Time.deltaTime * speed;
|
||||
movement += cam.transform.right * x * Time.deltaTime*speed;
|
||||
|
||||
movement += Vector3.down * 9.8f;
|
||||
if (!IsAiming)
|
||||
movement += cam.transform.right * x * Time.deltaTime * speed;
|
||||
else
|
||||
movement += cam.transform.right * x * Time.deltaTime * sideSpeed;
|
||||
|
||||
|
||||
|
||||
movement += Vector3.down*Time.deltaTime*9.8f;
|
||||
ccontroller.Move(movement);
|
||||
}
|
||||
|
||||
@ -110,21 +118,23 @@ public class PlayerMovementController : MonoBehaviour
|
||||
void Update()
|
||||
{
|
||||
if(isDead) return;
|
||||
AllowRotation = Input.GetMouseButton(1) || Input.GetAxis("Aim")>0.5f||IsRunning;
|
||||
AllowRotation = IsAiming||IsRunning;
|
||||
IsAiming = Input.GetMouseButton(1) || Input.GetAxis("Aim") > 0.5f;
|
||||
GetMovementOld();
|
||||
MovePlayer();
|
||||
|
||||
animcontroller.Animate(new Vector2(x, y), false,isRunning);
|
||||
|
||||
this.lookingDirectionVector = ((cameraController.Forward * y) + cameraController.Right * x).normalized;
|
||||
if (isRunning && !Input.GetMouseButtonDown(1)||AllowRotation)
|
||||
if (isRunning && !Input.GetMouseButtonDown(1) || AllowRotation)
|
||||
{
|
||||
if (AllowRotation && x == 0 && y == 0)
|
||||
if (AllowRotation && x == 0 && y == 0 || IsAiming && PlayerInteractionHandler.instance.GunEnabled)
|
||||
{
|
||||
this.lookingDirectionVector = cameraController.Forward.normalized;
|
||||
|
||||
}
|
||||
|
||||
SlowLookAt(this.lookingDirectionVector);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -146,6 +156,7 @@ public class PlayerMovementController : MonoBehaviour
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, toRotation, animatedRotationSpeed * Time.deltaTime);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PhysicalForceMove(Vector3 vector)
|
||||
{
|
||||
|
Reference in New Issue
Block a user