Add lighting and player movement
This commit is contained in:
parent
2939eecc8b
commit
d52cded64e
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:
|
20
Assets/ScriptableObjects/MoveStyles/Crouching.asset
Normal file
20
Assets/ScriptableObjects/MoveStyles/Crouching.asset
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
%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
|
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:
|
20
Assets/ScriptableObjects/MoveStyles/Running.asset
Normal file
20
Assets/ScriptableObjects/MoveStyles/Running.asset
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
%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
|
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 CameraPitch = 0;
|
||||||
|
|
||||||
|
private Player Player;
|
||||||
|
private InputAction LookAction;
|
||||||
|
private InputAction MoveAction;
|
||||||
|
private InputAction CrouchAction;
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
Player = GetComponent<Player>();
|
||||||
|
|
||||||
|
CrouchAction = new InputAction("crouch", binding: "<Gamepad>/leftCtrl");
|
||||||
|
CrouchAction.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();
|
||||||
|
|
||||||
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
|
Cursor.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update() {
|
||||||
|
OptionsData Opts = Options.Get();
|
||||||
|
Vector2 LookInput = LookAction.ReadValue<Vector2>() * Opts.LookSensitivity;
|
||||||
|
Vector3 CamEulers = Camera.localEulerAngles;
|
||||||
|
CamEulers.y += LookInput.x;
|
||||||
|
CameraPitch = Mathf.Clamp(CameraPitch - LookInput.y * (Opts.InvertVerticalLook ? -1 : 1), -90, 90);
|
||||||
|
CamEulers.x = CameraPitch;
|
||||||
|
Camera.localEulerAngles = CamEulers;
|
||||||
|
Player.HeadRotation = Camera.localRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// The player only moves on FixedUpdates, so movement-related inputs are handled here, so they get updated right before.
|
||||||
|
/// (Script execution order should ensure that LocalPlayer is run before Player.)
|
||||||
|
/// </remarks>
|
||||||
|
private void FixedUpdate() {
|
||||||
|
Vector2 MovementInput = MoveAction.ReadValue<Vector2>();
|
||||||
|
Vector3 Move = new Vector3(MovementInput.x, 0, MovementInput.y);
|
||||||
|
Vector3 Eulers = Player.HeadRotation.eulerAngles;
|
||||||
|
Eulers.z = 0;
|
||||||
|
Eulers.x = 0;
|
||||||
|
Move = Quaternion.Euler(Eulers) * Move;
|
||||||
|
Player.MoveDirection = Move;
|
||||||
|
Player.MoveStyle = CrouchAction.ReadValue<bool>() ? Player.CrouchingMoveStyle : Player.RunningMoveStyle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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:
|
20
Assets/Scripts/Player/MoveStyle.cs
Normal file
20
Assets/Scripts/Player/MoveStyle.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
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:
|
122
Assets/Scripts/Player/Player.cs
Normal file
122
Assets/Scripts/Player/Player.cs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
[Header("Player head status")]
|
||||||
|
/// <summary>The euler angle of the player's head.</summary>
|
||||||
|
public Quaternion HeadRotation;
|
||||||
|
|
||||||
|
[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.fixedTime - GroundedTime <= CoyoteTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Sets <c>Heading</c> via euler angles.</summary>
|
||||||
|
public void SetRotation(float xAngle, float yAngle) {
|
||||||
|
MoveDirection = Quaternion.Euler(xAngle, yAngle, 0) * Vector3.forward;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
CharacterController = GetComponent<CharacterController>();
|
||||||
|
FeetPosition = transform.position + CharacterController.center - Vector3.up * (CharacterController.height / 2 + CharacterController.skinWidth / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update() {
|
||||||
|
Head.localRotation = Quaternion.Lerp(Head.localRotation, HeadRotation, 10f * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate() {
|
||||||
|
bool Grounded = IsGrounded();
|
||||||
|
|
||||||
|
if (Grounded) {
|
||||||
|
GravitationalVelocity = Vector3.zero;
|
||||||
|
} else {
|
||||||
|
GravitationalVelocity += Physics.gravity * Time.fixedDeltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
float FrictionVelocityFactor = Mathf.Max(GroundVelocity.magnitude, MoveStyle.StopVelocity);
|
||||||
|
float Deccel = FrictionVelocityFactor * Time.fixedDeltaTime;
|
||||||
|
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.fixedDeltaTime;
|
||||||
|
if (Grounded) {
|
||||||
|
Acceleration *= MoveStyle.Acceleration;
|
||||||
|
} else {
|
||||||
|
Acceleration *= MoveStyle.AirAcceleration;
|
||||||
|
}
|
||||||
|
Acceleration = Mathf.Min(Acceleration, MoveStyle.TargetVelocity - CurrentSpeed);
|
||||||
|
GroundVelocity += FixedHeading * Acceleration;
|
||||||
|
|
||||||
|
CharacterController.Move((GroundVelocity + GravitationalVelocity) * Time.fixedDeltaTime);
|
||||||
|
if (CharacterController.isGrounded) {
|
||||||
|
GroundedTime = Time.fixedTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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:
|
@ -293,3 +293,195 @@ InputManager:
|
|||||||
type: 0
|
type: 0
|
||||||
axis: 0
|
axis: 0
|
||||||
joyNum: 0
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Enable Debug Button 1
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: left ctrl
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 8
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Enable Debug Button 2
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: backspace
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 9
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Reset
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: left alt
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 1
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Next
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: page down
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 5
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Previous
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: page up
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 4
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Validate
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: return
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 0
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Persistent
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: right shift
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 2
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Multiplier
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton:
|
||||||
|
positiveButton: left shift
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton: joystick button 3
|
||||||
|
gravity: 0
|
||||||
|
dead: 0
|
||||||
|
sensitivity: 0
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Horizontal
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton: left
|
||||||
|
positiveButton: right
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton:
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.001
|
||||||
|
sensitivity: 1000
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Vertical
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton: down
|
||||||
|
positiveButton: up
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton:
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.001
|
||||||
|
sensitivity: 1000
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 0
|
||||||
|
axis: 0
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Vertical
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton: down
|
||||||
|
positiveButton: up
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton:
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.001
|
||||||
|
sensitivity: 1000
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 2
|
||||||
|
axis: 6
|
||||||
|
joyNum: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
m_Name: Debug Horizontal
|
||||||
|
descriptiveName:
|
||||||
|
descriptiveNegativeName:
|
||||||
|
negativeButton: left
|
||||||
|
positiveButton: right
|
||||||
|
altNegativeButton:
|
||||||
|
altPositiveButton:
|
||||||
|
gravity: 1000
|
||||||
|
dead: 0.001
|
||||||
|
sensitivity: 1000
|
||||||
|
snap: 0
|
||||||
|
invert: 0
|
||||||
|
type: 2
|
||||||
|
axis: 5
|
||||||
|
joyNum: 0
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
"type": "UnityEngine.ProBuilder.SemVer, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
|
"type": "UnityEngine.ProBuilder.SemVer, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
|
||||||
"key": "preferences.version",
|
"key": "preferences.version",
|
||||||
"value": "{\"m_Value\":{\"m_Major\":4,\"m_Minor\":2,\"m_Patch\":3,\"m_Build\":-1,\"m_Type\":\"\",\"m_Metadata\":\"\",\"m_Date\":\"\"}}"
|
"value": "{\"m_Value\":{\"m_Major\":4,\"m_Minor\":2,\"m_Patch\":3,\"m_Build\":-1,\"m_Type\":\"\",\"m_Metadata\":\"\",\"m_Date\":\"\"}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
|
||||||
|
"key": "lightmapping.autoUnwrapLightmapUV",
|
||||||
|
"value": "{\"m_Value\":true}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ TagManager:
|
|||||||
- UI
|
- UI
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
- CollidableEnvironment
|
||||||
-
|
- BulletHitLayer
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
|
Loading…
Reference in New Issue
Block a user