From 16b0132f6cfe823a589e7f14d684be51e0173f95 Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Thu, 6 Aug 2020 22:58:31 +0300 Subject: [PATCH] Finish alicing --- Assets/Animation/Gun/GunIdle.anim | 12 +++--- Assets/Animation/Gun/GunWalk.anim | 10 ++--- Assets/Prefabs/LocalPlayer.prefab | 25 +++++++++-- .../DefaultPostProcessingVolumeProfile.asset | 31 ++++++++++++++ .../UniversalRenderPipelineAsset.asset | 2 +- Assets/Scripts/Animation/GunInterpolator.cs | 41 +++++++++++++++++++ ...llower.cs.meta => GunInterpolator.cs.meta} | 0 Assets/Scripts/Animation/LerpFollower.cs | 16 -------- Assets/Scripts/Player/LocalPlayer.cs | 2 +- 9 files changed, 107 insertions(+), 32 deletions(-) create mode 100644 Assets/Scripts/Animation/GunInterpolator.cs rename Assets/Scripts/Animation/{LerpFollower.cs.meta => GunInterpolator.cs.meta} (100%) delete mode 100644 Assets/Scripts/Animation/LerpFollower.cs diff --git a/Assets/Animation/Gun/GunIdle.anim b/Assets/Animation/Gun/GunIdle.anim index 14106af..c5e2905 100644 --- a/Assets/Animation/Gun/GunIdle.anim +++ b/Assets/Animation/Gun/GunIdle.anim @@ -72,7 +72,7 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: {x: 0, y: -0.19999993, z: 0.4} + value: {x: 0, y: -0.19999993, z: 0} inSlope: {x: 0, y: 0, z: 0} outSlope: {x: 0, y: 0, z: 0} tangentMode: 0 @@ -81,7 +81,7 @@ AnimationClip: outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} - serializedVersion: 3 time: 0.6666667 - value: {x: 0, y: -0.21, z: 0.405} + value: {x: 0, y: -0.21, z: 0.005} inSlope: {x: 0, y: 0, z: 0} outSlope: {x: 0, y: 0, z: 0} tangentMode: 0 @@ -90,7 +90,7 @@ AnimationClip: outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} - serializedVersion: 3 time: 1.3333334 - value: {x: 0, y: -0.19999993, z: 0.4} + value: {x: 0, y: -0.19999993, z: 0} inSlope: {x: 0, y: 0, z: 0} outSlope: {x: 0, y: 0, z: 0} tangentMode: 0 @@ -226,7 +226,7 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: 0.4 + value: 0 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -235,7 +235,7 @@ AnimationClip: outWeight: 0.33333334 - serializedVersion: 3 time: 0.6666667 - value: 0.405 + value: 0.005 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -244,7 +244,7 @@ AnimationClip: outWeight: 0.33333334 - serializedVersion: 3 time: 1.3333334 - value: 0.4 + value: 0 inSlope: 0 outSlope: 0 tangentMode: 136 diff --git a/Assets/Animation/Gun/GunWalk.anim b/Assets/Animation/Gun/GunWalk.anim index 133fe1b..5c281b2 100644 --- a/Assets/Animation/Gun/GunWalk.anim +++ b/Assets/Animation/Gun/GunWalk.anim @@ -20,7 +20,7 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: {x: 0, y: -0.19999993, z: 0.4} + value: {x: 0, y: -0.19999993, z: 0} inSlope: {x: 0, y: 0.045422196, z: 0} outSlope: {x: 0, y: 0.045422196, z: 0} tangentMode: 0 @@ -29,7 +29,7 @@ AnimationClip: outWeight: {x: 0.33333334, y: 0.21276595, z: 0.33333334} - serializedVersion: 3 time: 0.23333333 - value: {x: 0, y: -0.19, z: 0.4} + value: {x: 0, y: -0.19, z: 0} inSlope: {x: 0, y: 0.0036644656, z: 0} outSlope: {x: 0, y: 0.0036644656, z: 0} tangentMode: 0 @@ -38,7 +38,7 @@ AnimationClip: outWeight: {x: 0.33333334, y: 0.54491717, z: 0.33333334} - serializedVersion: 3 time: 0.45 - value: {x: 0, y: -0.19999993, z: 0.4} + value: {x: 0, y: -0.19999993, z: 0} inSlope: {x: 0, y: 0.08186936, z: 0} outSlope: {x: 0, y: 0.08186936, z: 0} tangentMode: 0 @@ -158,7 +158,7 @@ AnimationClip: m_Curve: - serializedVersion: 3 time: 0 - value: 0.4 + value: 0 inSlope: 0 outSlope: 0 tangentMode: 136 @@ -167,7 +167,7 @@ AnimationClip: outWeight: 0.33333334 - serializedVersion: 3 time: 0.45 - value: 0.4 + value: 0 inSlope: 0 outSlope: 0 tangentMode: 136 diff --git a/Assets/Prefabs/LocalPlayer.prefab b/Assets/Prefabs/LocalPlayer.prefab index 3ba7127..12b8add 100644 --- a/Assets/Prefabs/LocalPlayer.prefab +++ b/Assets/Prefabs/LocalPlayer.prefab @@ -925,6 +925,7 @@ GameObject: m_Component: - component: {fileID: 7391558913374292208} - component: {fileID: 5888965224432224917} + - component: {fileID: 703637974133461687} m_Layer: 0 m_Name: GunRoot m_TagString: Untagged @@ -939,8 +940,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7391558913374292223} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.15, y: 0, z: 0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0.15, y: -0.04, z: 0.4} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 7391558913422139240} @@ -966,6 +967,24 @@ Animator: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorControllerStateOnDisable: 0 +--- !u!114 &703637974133461687 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7391558913374292223} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 22a7da1b361417640853a9cdcde28400, type: 3} + m_Name: + m_EditorClassIdentifier: + Player: {fileID: 7391558912774766620} + InterpolationSpeed: 5 + YawDegrees: 7 + PitchDegrees: 7 + RollDegrees: 7 + RotationThreshold: 5 --- !u!1 &7391558913422139223 GameObject: m_ObjectHideFlags: 0 @@ -990,7 +1009,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7391558913422139223} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: -0.19999993, z: 0.4} + m_LocalPosition: {x: 0, y: -0.19999993, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 7391558913269936983} diff --git a/Assets/RenderPipeline/DefaultPostProcessingVolumeProfile.asset b/Assets/RenderPipeline/DefaultPostProcessingVolumeProfile.asset index d0eecb1..90596d6 100644 --- a/Assets/RenderPipeline/DefaultPostProcessingVolumeProfile.asset +++ b/Assets/RenderPipeline/DefaultPostProcessingVolumeProfile.asset @@ -47,6 +47,36 @@ MonoBehaviour: m_OverrideState: 0 m_Value: 0 min: 0 +--- !u!114 &-3919862544555392601 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 29fa0085f50d5e54f8144f766051a691, type: 3} + m_Name: FilmGrain + m_EditorClassIdentifier: + active: 1 + m_AdvancedMode: 0 + type: + m_OverrideState: 0 + m_Value: 0 + intensity: + m_OverrideState: 1 + m_Value: 0.1 + min: 0 + max: 1 + response: + m_OverrideState: 0 + m_Value: 0.8 + min: 0 + max: 1 + texture: + m_OverrideState: 0 + m_Value: {fileID: 0} --- !u!114 &-1329204002016237937 MonoBehaviour: m_ObjectHideFlags: 3 @@ -83,6 +113,7 @@ MonoBehaviour: - {fileID: 7991213835716202865} - {fileID: 4212929005619836917} - {fileID: -1329204002016237937} + - {fileID: -3919862544555392601} --- !u!114 &4212929005619836917 MonoBehaviour: m_ObjectHideFlags: 3 diff --git a/Assets/RenderPipeline/UniversalRenderPipelineAsset.asset b/Assets/RenderPipeline/UniversalRenderPipelineAsset.asset index 3763216..f9a6b6b 100644 --- a/Assets/RenderPipeline/UniversalRenderPipelineAsset.asset +++ b/Assets/RenderPipeline/UniversalRenderPipelineAsset.asset @@ -42,7 +42,7 @@ MonoBehaviour: m_SoftShadowsSupported: 1 m_UseSRPBatcher: 1 m_SupportsDynamicBatching: 0 - m_MixedLightingSupported: 1 + m_MixedLightingSupported: 0 m_DebugLevel: 0 m_UseAdaptivePerformance: 1 m_ColorGradingMode: 1 diff --git a/Assets/Scripts/Animation/GunInterpolator.cs b/Assets/Scripts/Animation/GunInterpolator.cs new file mode 100644 index 0000000..1d83aca --- /dev/null +++ b/Assets/Scripts/Animation/GunInterpolator.cs @@ -0,0 +1,41 @@ +using UnityEngine; +using NeonTea.Quakeball.Player; + +namespace NeonTea.Quakeball.Animation { + /// Lags a little behind every frame to create a delay effect in the gun movement. + public class GunInterpolator : MonoBehaviour { + public LocalPlayer Player; + public float InterpolationSpeed; + public float YawDegrees; + public float PitchDegrees; + public float RollDegrees; + public float RotationThreshold; + + private Vector2 CurrentLean = Vector2.zero; + private Vector2 TargetLean = Vector2.zero; + + private void Update() { + Vector2 LookDelta = Player.LookAction.ReadValue(); + SetTarget(LookDelta.x, ref TargetLean.x); + CurrentLean.x = Mathf.Lerp(CurrentLean.x, TargetLean.x, InterpolationSpeed * Time.deltaTime); + SetTarget(LookDelta.y, ref TargetLean.y); + CurrentLean.y = Mathf.Lerp(CurrentLean.y, TargetLean.y, InterpolationSpeed * Time.deltaTime); + + Vector3 Eulers = transform.localEulerAngles; + Eulers.x = -CurrentLean.y * PitchDegrees; + Eulers.y = CurrentLean.x * YawDegrees; + Eulers.z = CurrentLean.x * RollDegrees; + transform.localEulerAngles = Eulers; + } + + private void SetTarget(float delta, ref float targetLean) { + if (delta > RotationThreshold) { + targetLean = -1; + } else if (delta < -RotationThreshold) { + targetLean = 1; + } else { + targetLean = Mathf.Lerp(targetLean, 0, 10f * Time.deltaTime); + } + } + } +} diff --git a/Assets/Scripts/Animation/LerpFollower.cs.meta b/Assets/Scripts/Animation/GunInterpolator.cs.meta similarity index 100% rename from Assets/Scripts/Animation/LerpFollower.cs.meta rename to Assets/Scripts/Animation/GunInterpolator.cs.meta diff --git a/Assets/Scripts/Animation/LerpFollower.cs b/Assets/Scripts/Animation/LerpFollower.cs deleted file mode 100644 index 70b7cde..0000000 --- a/Assets/Scripts/Animation/LerpFollower.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace NeonTea.Quakeball.Animation { - /// Follows a Transform with configurable lerp speeds. - public class LerpFollower : MonoBehaviour { - public Transform Followed; - public Vector3 PositionLerpSpeed = new Vector3(100, 100, 100); - public Vector3 RotationLerpSpeed = new Vector3(100, 100, 100); - public Vector3 ScaleLerpSpeed = new Vector3(100, 100, 100); - - private void Update() { - } - } -} diff --git a/Assets/Scripts/Player/LocalPlayer.cs b/Assets/Scripts/Player/LocalPlayer.cs index 9dbb357..5b75fce 100644 --- a/Assets/Scripts/Player/LocalPlayer.cs +++ b/Assets/Scripts/Player/LocalPlayer.cs @@ -12,7 +12,7 @@ namespace NeonTea.Quakeball.Player { private float Lean = 0; private Player Player; - private InputAction LookAction; + public InputAction LookAction { private set; get; } private InputAction MoveAction; private InputAction CrouchAction; private InputAction JumpAction;