Merge branch 'master' of teascade.net:neontea/quakeball
This commit is contained in:
commit
db1d3bb671
8
Assets/RenderPipeline.meta
Normal file
8
Assets/RenderPipeline.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 816a0d14526c1de4d969eba2857628d8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
63
Assets/RenderPipeline/DefaultLightingSettings.lighting
Normal file
63
Assets/RenderPipeline/DefaultLightingSettings.lighting
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!850595691 &4890085278179872738
|
||||||
|
LightingSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: DefaultLightingSettings
|
||||||
|
serializedVersion: 2
|
||||||
|
m_GIWorkflowMode: 1
|
||||||
|
m_EnableBakedLightmaps: 1
|
||||||
|
m_EnableRealtimeLightmaps: 0
|
||||||
|
m_RealtimeEnvironmentLighting: 1
|
||||||
|
m_BounceScale: 1
|
||||||
|
m_AlbedoBoost: 1
|
||||||
|
m_IndirectOutputScale: 1
|
||||||
|
m_UsingShadowmask: 1
|
||||||
|
m_BakeBackend: 1
|
||||||
|
m_LightmapMaxSize: 1024
|
||||||
|
m_BakeResolution: 40
|
||||||
|
m_Padding: 2
|
||||||
|
m_TextureCompression: 1
|
||||||
|
m_AO: 0
|
||||||
|
m_AOMaxDistance: 1
|
||||||
|
m_CompAOExponent: 1
|
||||||
|
m_CompAOExponentDirect: 0
|
||||||
|
m_ExtractAO: 0
|
||||||
|
m_MixedBakeMode: 2
|
||||||
|
m_LightmapsBakeMode: 1
|
||||||
|
m_FilterMode: 1
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_ExportTrainingData: 0
|
||||||
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_RealtimeResolution: 2
|
||||||
|
m_ForceWhiteAlbedo: 0
|
||||||
|
m_ForceUpdates: 0
|
||||||
|
m_FinalGather: 0
|
||||||
|
m_FinalGatherRayCount: 256
|
||||||
|
m_FinalGatherFiltering: 1
|
||||||
|
m_PVRCulling: 1
|
||||||
|
m_PVRSampling: 1
|
||||||
|
m_PVRDirectSampleCount: 32
|
||||||
|
m_PVRSampleCount: 512
|
||||||
|
m_PVREnvironmentSampleCount: 256
|
||||||
|
m_PVREnvironmentReferencePointCount: 2048
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
|
m_PVRBounces: 2
|
||||||
|
m_PVRRussianRouletteStartBounce: 2
|
||||||
|
m_PVREnvironmentMIS: 1
|
||||||
|
m_PVRFilteringMode: 1
|
||||||
|
m_PVRDenoiserTypeDirect: 1
|
||||||
|
m_PVRDenoiserTypeIndirect: 1
|
||||||
|
m_PVRDenoiserTypeAO: 1
|
||||||
|
m_PVRFilterTypeDirect: 0
|
||||||
|
m_PVRFilterTypeIndirect: 0
|
||||||
|
m_PVRFilterTypeAO: 0
|
||||||
|
m_PVRFilteringGaussRadiusDirect: 1
|
||||||
|
m_PVRFilteringGaussRadiusIndirect: 5
|
||||||
|
m_PVRFilteringGaussRadiusAO: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||||
|
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eab3e4c589c0a1147a910511c80f5e0c
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
55
Assets/RenderPipeline/UniversalRenderPipelineAsset.asset
Normal file
55
Assets/RenderPipeline/UniversalRenderPipelineAsset.asset
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
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: bf2edee5c58d82540a51f03df9d42094, type: 3}
|
||||||
|
m_Name: UniversalRenderPipelineAsset
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
k_AssetVersion: 5
|
||||||
|
k_AssetPreviousVersion: 5
|
||||||
|
m_RendererType: 1
|
||||||
|
m_RendererData: {fileID: 0}
|
||||||
|
m_RendererDataList:
|
||||||
|
- {fileID: 11400000, guid: 329556371b5b38d4b97bf007b4a0cfcb, type: 2}
|
||||||
|
m_DefaultRendererIndex: 0
|
||||||
|
m_RequireDepthTexture: 0
|
||||||
|
m_RequireOpaqueTexture: 0
|
||||||
|
m_OpaqueDownsampling: 1
|
||||||
|
m_SupportsTerrainHoles: 1
|
||||||
|
m_SupportsHDR: 1
|
||||||
|
m_MSAA: 4
|
||||||
|
m_RenderScale: 1
|
||||||
|
m_MainLightRenderingMode: 1
|
||||||
|
m_MainLightShadowsSupported: 1
|
||||||
|
m_MainLightShadowmapResolution: 2048
|
||||||
|
m_AdditionalLightsRenderingMode: 1
|
||||||
|
m_AdditionalLightsPerObjectLimit: 4
|
||||||
|
m_AdditionalLightShadowsSupported: 0
|
||||||
|
m_AdditionalLightsShadowmapResolution: 512
|
||||||
|
m_ShadowDistance: 50
|
||||||
|
m_ShadowCascades: 0
|
||||||
|
m_Cascade2Split: 0.25
|
||||||
|
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
|
||||||
|
m_ShadowDepthBias: 1
|
||||||
|
m_ShadowNormalBias: 1
|
||||||
|
m_SoftShadowsSupported: 1
|
||||||
|
m_UseSRPBatcher: 1
|
||||||
|
m_SupportsDynamicBatching: 0
|
||||||
|
m_MixedLightingSupported: 1
|
||||||
|
m_DebugLevel: 0
|
||||||
|
m_UseAdaptivePerformance: 1
|
||||||
|
m_ColorGradingMode: 1
|
||||||
|
m_ColorGradingLutSize: 32
|
||||||
|
m_ShadowType: 1
|
||||||
|
m_LocalShadowsSupported: 0
|
||||||
|
m_LocalShadowsAtlasResolution: 256
|
||||||
|
m_MaxPixelLights: 0
|
||||||
|
m_ShadowAtlasResolution: 256
|
||||||
|
m_ShaderVariantLogLevel: 0
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 714d5817425984e47bcc98849464c172
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,37 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
|
||||||
|
m_Name: UniversalRenderPipelineAsset_Renderer
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_RendererFeatures: []
|
||||||
|
m_RendererFeatureMap:
|
||||||
|
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
||||||
|
shaders:
|
||||||
|
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
|
||||||
|
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
|
||||||
|
screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, type: 3}
|
||||||
|
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
|
||||||
|
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
|
||||||
|
m_OpaqueLayerMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_TransparentLayerMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_DefaultStencilState:
|
||||||
|
overrideStencilState: 0
|
||||||
|
stencilReference: 0
|
||||||
|
stencilCompareFunction: 8
|
||||||
|
passOperation: 0
|
||||||
|
failOperation: 0
|
||||||
|
zFailOperation: 0
|
||||||
|
m_ShadowTransparentReceive: 1
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 329556371b5b38d4b97bf007b4a0cfcb
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/ScriptableObjects.meta
Normal file
8
Assets/ScriptableObjects.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e5509da920e35841a6845fa3d020421
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/ScriptableObjects/MoveStyles.meta
Normal file
8
Assets/ScriptableObjects/MoveStyles.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 74af483c66a70cf49aa4d45415d2cfcd
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
22
Assets/ScriptableObjects/MoveStyles/Crouching.asset
Normal file
22
Assets/ScriptableObjects/MoveStyles/Crouching.asset
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
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: c7827ce96d9ff12458f0de236abbab9b, type: 3}
|
||||||
|
m_Name: Crouching
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
TargetVelocity: 4
|
||||||
|
StopVelocity: 3
|
||||||
|
Acceleration: 20
|
||||||
|
AirAcceleration: 15
|
||||||
|
Friction: 20
|
||||||
|
AirFriction: 15
|
||||||
|
JumpVelocity: 5
|
||||||
|
LeanDegrees: 1
|
8
Assets/ScriptableObjects/MoveStyles/Crouching.asset.meta
Normal file
8
Assets/ScriptableObjects/MoveStyles/Crouching.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d9739d3745581a41ae0ed6a569766d5
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
22
Assets/ScriptableObjects/MoveStyles/Running.asset
Normal file
22
Assets/ScriptableObjects/MoveStyles/Running.asset
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
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: c7827ce96d9ff12458f0de236abbab9b, type: 3}
|
||||||
|
m_Name: Running
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
TargetVelocity: 10
|
||||||
|
StopVelocity: 3
|
||||||
|
Acceleration: 10
|
||||||
|
AirAcceleration: 5
|
||||||
|
Friction: 8
|
||||||
|
AirFriction: 4
|
||||||
|
JumpVelocity: 8
|
||||||
|
LeanDegrees: 2
|
8
Assets/ScriptableObjects/MoveStyles/Running.asset.meta
Normal file
8
Assets/ScriptableObjects/MoveStyles/Running.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 550df8ac62d76a64a8c621ea6b32398f
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
19
Assets/Scripts/Options.cs
Normal file
19
Assets/Scripts/Options.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball {
|
||||||
|
/// <summary>Container for user-selected options.</summary>
|
||||||
|
public class OptionsData {
|
||||||
|
public bool InvertVerticalLook = false;
|
||||||
|
public float LookSensitivity = 0.15f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Options : MonoBehaviour {
|
||||||
|
private static OptionsData Singleton = new OptionsData();
|
||||||
|
|
||||||
|
public static OptionsData Get() {
|
||||||
|
return Singleton;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Options.cs.meta
Normal file
11
Assets/Scripts/Options.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ca0b306afdebee4a9258b12c4ca457b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/Scripts/Player.meta
Normal file
8
Assets/Scripts/Player.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 547a2f92b7463b5479ca4bf370d32fa6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
65
Assets/Scripts/Player/LocalPlayer.cs
Normal file
65
Assets/Scripts/Player/LocalPlayer.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Player {
|
||||||
|
/// <summary>A controller class for a local player. Handles input and updates the relevant components.</summary>
|
||||||
|
[RequireComponent(typeof(Player))]
|
||||||
|
public class LocalPlayer : MonoBehaviour {
|
||||||
|
public Transform Camera;
|
||||||
|
|
||||||
|
private float Lean = 0;
|
||||||
|
|
||||||
|
private Player Player;
|
||||||
|
private InputAction LookAction;
|
||||||
|
private InputAction MoveAction;
|
||||||
|
private InputAction CrouchAction;
|
||||||
|
private InputAction JumpAction;
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
Player = GetComponent<Player>();
|
||||||
|
|
||||||
|
CrouchAction = new InputAction("crouch", binding: "<Gamepad>/buttonEast");
|
||||||
|
CrouchAction.AddBinding("<Keyboard>/leftShift");
|
||||||
|
CrouchAction.Enable();
|
||||||
|
|
||||||
|
JumpAction = new InputAction("crouch", binding: "<Gamepad>/buttonSouth");
|
||||||
|
JumpAction.AddBinding("<Keyboard>/space");
|
||||||
|
JumpAction.Enable();
|
||||||
|
|
||||||
|
LookAction = new InputAction("look", binding: "<Gamepad>/leftStick");
|
||||||
|
LookAction.AddBinding("<Mouse>/delta");
|
||||||
|
LookAction.Enable();
|
||||||
|
|
||||||
|
MoveAction = new InputAction("move", binding: "<Gamepad>/rightStick");
|
||||||
|
MoveAction.AddCompositeBinding("Dpad")
|
||||||
|
.With("Up", "<Keyboard>/w")
|
||||||
|
.With("Down", "<Keyboard>/s")
|
||||||
|
.With("Left", "<Keyboard>/a")
|
||||||
|
.With("Right", "<Keyboard>/d");
|
||||||
|
MoveAction.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start() {
|
||||||
|
Cursor.visible = false;
|
||||||
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update() {
|
||||||
|
OptionsData Opts = Options.Get();
|
||||||
|
|
||||||
|
Vector2 MovementInput = MoveAction.ReadValue<Vector2>();
|
||||||
|
Vector3 Move = new Vector3(MovementInput.x, 0, MovementInput.y);
|
||||||
|
Move = Quaternion.Euler(0, Player.Yaw, 0) * Move;
|
||||||
|
Player.MoveDirection = Move;
|
||||||
|
Player.MoveStyle = CrouchAction.ReadValue<float>() > 0 ? Player.CrouchingMoveStyle : Player.RunningMoveStyle;
|
||||||
|
Player.Jumping = JumpAction.ReadValue<float>() > 0;
|
||||||
|
|
||||||
|
Vector2 LookInput = LookAction.ReadValue<Vector2>() * Opts.LookSensitivity;
|
||||||
|
Player.Pitch = Mathf.Clamp(Player.Pitch - LookInput.y * (Opts.InvertVerticalLook ? -1 : 1), -90, 90);
|
||||||
|
Player.Yaw += LookInput.x;
|
||||||
|
float TargetLean = -Vector3.Dot(Player.GroundVelocity / Player.MoveStyle.TargetVelocity, Camera.right) * Player.MoveStyle.LeanDegrees;
|
||||||
|
Lean = Mathf.Lerp(Lean, TargetLean, 10f * Time.deltaTime);
|
||||||
|
Camera.localEulerAngles = new Vector3(Player.Pitch, Player.Yaw, Lean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Player/LocalPlayer.cs.meta
Normal file
11
Assets/Scripts/Player/LocalPlayer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f6e08271c272323469510daa22c35599
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: -20
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
24
Assets/Scripts/Player/MoveStyle.cs
Normal file
24
Assets/Scripts/Player/MoveStyle.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Player {
|
||||||
|
/// <summary>Different modes of transportation.</summary>
|
||||||
|
[CreateAssetMenu(fileName = "Moving", menuName = "Quakeball/MoveStyle")]
|
||||||
|
public class MoveStyle : ScriptableObject {
|
||||||
|
/// <summary>The target velocity to accelerate towards.</summary>
|
||||||
|
public float TargetVelocity;
|
||||||
|
/// <summary>When decelerating, the speed at which the deceleration no longer decelerates.</summary>
|
||||||
|
public float StopVelocity;
|
||||||
|
/// <summary>The acceleration coefficient. Higher values mean faster acceleration.</summary>
|
||||||
|
public float Acceleration;
|
||||||
|
/// <summary>The acceleration coefficient in air. Higher values mean faster acceleration.</summary>
|
||||||
|
public float AirAcceleration;
|
||||||
|
/// <summary>The friction coefficient. Higher values mean faster slowdown, should be less than or equal to <c>Acceleration</c>.</summary>
|
||||||
|
public float Friction;
|
||||||
|
/// <summary>The friction coefficient in air. Higher values mean faster slowdown, should be less than or equal to <c>Acceleration</c>.</summary>
|
||||||
|
public float AirFriction;
|
||||||
|
/// <summary>The velocity that the player jumps in this style.</summary>
|
||||||
|
public float JumpVelocity;
|
||||||
|
/// <summary>Degrees that the player leans when moving sideways in this style.</summary>
|
||||||
|
public float LeanDegrees;
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/Player/MoveStyle.cs.meta
Normal file
11
Assets/Scripts/Player/MoveStyle.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c7827ce96d9ff12458f0de236abbab9b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
132
Assets/Scripts/Player/Player.cs
Normal file
132
Assets/Scripts/Player/Player.cs
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NeonTea.Quakeball.Player {
|
||||||
|
/// <summary>The central glue class for players (both local and remote).</summary>
|
||||||
|
/// <remarks>Other classes will handle netcode/inputs, and then speak to this class in order to make the little people run around.</remarks>
|
||||||
|
[RequireComponent(typeof(CharacterController))]
|
||||||
|
public class Player : MonoBehaviour {
|
||||||
|
|
||||||
|
/// <summary>How long after running off a cliff should the player be considered "on ground"?</summary>
|
||||||
|
public float CoyoteTime;
|
||||||
|
|
||||||
|
public MoveStyle RunningMoveStyle;
|
||||||
|
public MoveStyle CrouchingMoveStyle;
|
||||||
|
public Transform Head;
|
||||||
|
public Transform Body;
|
||||||
|
|
||||||
|
[Header("Player rotation status")]
|
||||||
|
/// <summary>The pitch of the player's head.</summary>
|
||||||
|
public float Pitch;
|
||||||
|
/// <summary>The total yaw of the player. Head yaw is Yaw - BodyYaw.</summary>
|
||||||
|
public float Yaw;
|
||||||
|
/// <summary>The yaw of the player body. Calculated from MoveDirection.</summary>
|
||||||
|
public float BodyYaw;
|
||||||
|
|
||||||
|
[Header("Player movement status")]
|
||||||
|
/// <summary>The direction the player is going.</summary>
|
||||||
|
public Vector3 MoveDirection;
|
||||||
|
|
||||||
|
/// <summary>The player's desire to jump currently.</summary>
|
||||||
|
public bool Jumping;
|
||||||
|
|
||||||
|
/// <summary>The amount of movement the player wants to happen.</summary>
|
||||||
|
/// <remarks>Without analog controls, always 0 or 1.</remarks>
|
||||||
|
public float InputSpeed;
|
||||||
|
|
||||||
|
/// <summary>The way the player is moving.</summary>
|
||||||
|
public MoveStyle MoveStyle;
|
||||||
|
|
||||||
|
[Header("Runtime computed values")]
|
||||||
|
/// <summary>The speed at which the player is currently moving across the ground.</summary>
|
||||||
|
public Vector3 GroundVelocity;
|
||||||
|
|
||||||
|
/// <summary>The speed at which the player is rising or falling.</summary>
|
||||||
|
public Vector3 GravitationalVelocity;
|
||||||
|
|
||||||
|
/// <summary>The timestamp of when the player was last on the ground.</summary>
|
||||||
|
public float GroundedTime;
|
||||||
|
|
||||||
|
[Header("Misc. technical knobs")]
|
||||||
|
public float GroundCastLength = 0.2f;
|
||||||
|
public LayerMask GroundLayer;
|
||||||
|
|
||||||
|
[Header("Debug settings")]
|
||||||
|
public bool ShowGroundCast;
|
||||||
|
|
||||||
|
private CharacterController CharacterController;
|
||||||
|
private Vector3 FeetPosition;
|
||||||
|
|
||||||
|
/// <summary>The normal of the ground below the player. If there is no ground, it's <c>Vector3.up</c> by default.</summary>
|
||||||
|
public Vector3 GroundCast() {
|
||||||
|
RaycastHit Hit;
|
||||||
|
if (ShowGroundCast) {
|
||||||
|
Debug.DrawLine(FeetPosition, FeetPosition - Vector3.up, Color.red, 1f);
|
||||||
|
}
|
||||||
|
if (Physics.Raycast(FeetPosition, -Vector3.up, out Hit, GroundCastLength, GroundLayer)) {
|
||||||
|
return Hit.normal;
|
||||||
|
} else {
|
||||||
|
return Vector3.up;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsGrounded() {
|
||||||
|
return Time.time - GroundedTime <= CoyoteTime && Vector3.Dot(GravitationalVelocity, Vector3.down) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
CharacterController = GetComponent<CharacterController>();
|
||||||
|
FeetPosition = transform.position + CharacterController.center - Vector3.up * (CharacterController.height / 2 + CharacterController.skinWidth / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update() {
|
||||||
|
if (MoveDirection.magnitude > 0) {
|
||||||
|
BodyYaw = Vector3.SignedAngle(Vector3.forward, MoveDirection, Vector3.up);
|
||||||
|
}
|
||||||
|
Body.localRotation = Quaternion.Lerp(Body.localRotation, Quaternion.Euler(0, BodyYaw, 0), 20f * Time.deltaTime);
|
||||||
|
Head.localRotation = Quaternion.Lerp(Head.localRotation, Quaternion.Euler(Pitch, Yaw - BodyYaw, 0), 15f * Time.deltaTime);
|
||||||
|
UpdateMovement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateMovement() {
|
||||||
|
bool Grounded = IsGrounded();
|
||||||
|
|
||||||
|
if (Grounded) {
|
||||||
|
if (Vector3.Dot(Vector3.down, GravitationalVelocity) > 0) {
|
||||||
|
GravitationalVelocity = Vector3.zero;
|
||||||
|
}
|
||||||
|
if (Jumping) {
|
||||||
|
GravitationalVelocity = Vector3.up * MoveStyle.JumpVelocity;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GravitationalVelocity += Physics.gravity * Time.deltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
float FrictionVelocityFactor = Mathf.Max(GroundVelocity.magnitude, MoveStyle.StopVelocity);
|
||||||
|
float Deccel = FrictionVelocityFactor * Time.deltaTime;
|
||||||
|
if (Grounded) {
|
||||||
|
Deccel *= MoveStyle.Friction;
|
||||||
|
} else {
|
||||||
|
Deccel *= MoveStyle.AirFriction;
|
||||||
|
}
|
||||||
|
float FrictionedVelocity = Mathf.Max(0, GroundVelocity.magnitude - Deccel);
|
||||||
|
GroundVelocity = GroundVelocity.normalized * FrictionedVelocity;
|
||||||
|
|
||||||
|
Vector3 GroundNormal = GroundCast();
|
||||||
|
Vector3 FixedHeading = Vector3.ProjectOnPlane(MoveDirection, GroundNormal).normalized;
|
||||||
|
float CurrentSpeed = Vector3.Dot(GroundVelocity, FixedHeading);
|
||||||
|
float Acceleration = MoveStyle.TargetVelocity * Time.deltaTime;
|
||||||
|
if (Grounded) {
|
||||||
|
Acceleration *= MoveStyle.Acceleration;
|
||||||
|
} else {
|
||||||
|
Acceleration *= MoveStyle.AirAcceleration;
|
||||||
|
}
|
||||||
|
Acceleration = Mathf.Min(Acceleration, MoveStyle.TargetVelocity - CurrentSpeed);
|
||||||
|
GroundVelocity += FixedHeading * Acceleration;
|
||||||
|
|
||||||
|
CharacterController.Move((GroundVelocity + GravitationalVelocity) * Time.deltaTime);
|
||||||
|
if (CharacterController.isGrounded) {
|
||||||
|
GroundedTime = Time.time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Assets/Scripts/Player/Player.cs.meta
Normal file
15
Assets/Scripts/Player/Player.cs.meta
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 40221663adaa8b54cb9b9f81042bd6b3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences:
|
||||||
|
- RunningMoveStyle: {fileID: 11400000, guid: 550df8ac62d76a64a8c621ea6b32398f, type: 2}
|
||||||
|
- CrouchingMoveStyle: {fileID: 11400000, guid: 2d9739d3745581a41ae0ed6a569766d5, type: 2}
|
||||||
|
- Head: {instanceID: 0}
|
||||||
|
- MoveStyle: {instanceID: 0}
|
||||||
|
executionOrder: 5
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -3,10 +3,11 @@
|
|||||||
--- !u!55 &1
|
--- !u!55 &1
|
||||||
PhysicsManager:
|
PhysicsManager:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 11
|
serializedVersion: 13
|
||||||
m_Gravity: {x: 0, y: -9.81, z: 0}
|
m_Gravity: {x: 0, y: -20, z: 0}
|
||||||
m_DefaultMaterial: {fileID: 0}
|
m_DefaultMaterial: {fileID: 0}
|
||||||
m_BounceThreshold: 2
|
m_BounceThreshold: 2
|
||||||
|
m_DefaultMaxDepenetrationVelocity: 10
|
||||||
m_SleepThreshold: 0.005
|
m_SleepThreshold: 0.005
|
||||||
m_DefaultContactOffset: 0.01
|
m_DefaultContactOffset: 0.01
|
||||||
m_DefaultSolverIterations: 6
|
m_DefaultSolverIterations: 6
|
||||||
@ -22,6 +23,7 @@ PhysicsManager:
|
|||||||
m_AutoSyncTransforms: 0
|
m_AutoSyncTransforms: 0
|
||||||
m_ReuseCollisionCallbacks: 1
|
m_ReuseCollisionCallbacks: 1
|
||||||
m_ClothInterCollisionSettingsToggle: 0
|
m_ClothInterCollisionSettingsToggle: 0
|
||||||
|
m_ClothGravity: {x: 0, y: -9.81, z: 0}
|
||||||
m_ContactPairsMode: 0
|
m_ContactPairsMode: 0
|
||||||
m_BroadphaseType: 0
|
m_BroadphaseType: 0
|
||||||
m_WorldBounds:
|
m_WorldBounds:
|
||||||
@ -31,4 +33,5 @@ PhysicsManager:
|
|||||||
m_FrictionType: 0
|
m_FrictionType: 0
|
||||||
m_EnableEnhancedDeterminism: 0
|
m_EnableEnhancedDeterminism: 0
|
||||||
m_EnableUnifiedHeightmaps: 1
|
m_EnableUnifiedHeightmaps: 1
|
||||||
m_DefaultMaxAngluarSpeed: 7
|
m_SolverType: 0
|
||||||
|
m_DefaultMaxAngularSpeed: 7
|
||||||
|
@ -13,9 +13,9 @@ TagManager:
|
|||||||
- UI
|
- UI
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
- CollidableEnvironment
|
||||||
-
|
- BulletHitLayer
|
||||||
-
|
- InvisibleToPlayerCamera
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
|
Loading…
Reference in New Issue
Block a user