Uppdatering av PlayerControls

This commit is contained in:
2026-09-16 19:50:16 +02:00
parent 351a04974f
commit e3a089d034
10 changed files with 224 additions and 173 deletions

View File

@@ -16,6 +16,8 @@ public class BallController : MonoBehaviour {
float _jumpForce;
Rigidbody _ball;
float _outOfBounds = -1.8f;
private Vector2 _moveInput;
private PlayerControls _controls;
void Start() {
_ball = GetComponent<Rigidbody>();
@@ -25,9 +27,43 @@ public class BallController : MonoBehaviour {
_pickupLeft = GameObject.FindGameObjectsWithTag("PickUp").Length;
transform.position = new Vector3(0, 0.5f, 0);
}
private void Awake() {
_controls = new PlayerControls();
}
private void OnEnable() {
_controls.Enable();
_controls.Player.Move.performed += ctx =>
_moveInput = ctx.ReadValue<Vector2>();
_controls.Player.Move.canceled += ctx =>
_moveInput = Vector2.zero;
_controls.Player.Jump.performed += ctx => {
Debug.Log("SPACE TRYCKT");
if (transform.position.y < 1) {
_ball.AddForce(Vector3.up * _jumpForce);
}
};
}
public void OnMove(InputAction.CallbackContext context) {
_moveInput = context.ReadValue<Vector2>();
}
private void FixedUpdate() {
Vector3 direction =
new Vector3(_moveInput.x, 0, _moveInput.y);
_ball.AddForce(direction * _ballSpeed);
if (direction == Vector3.zero) {
_ball.AddForce(-_ball.linearVelocity * _brakeForce);
}
}
void Update() {
KeyHandler();
//KeyHandler();
CheckPlayerOut();
UpdateGUI();
}
@@ -60,6 +96,7 @@ public class BallController : MonoBehaviour {
}
}
/*
void KeyHandler() {
if (Keyboard.current.wKey.isPressed) {
_ball.AddForce(Vector3.forward * _ballSpeed);
@@ -80,4 +117,5 @@ public class BallController : MonoBehaviour {
_ball.AddForce(-_ball.linearVelocity * _brakeForce);
}
}
*/
}

View File

@@ -19,9 +19,10 @@ MonoBehaviour:
m_StripRuntimeDebugShaders: 1
m_URPShaderStrippingSetting:
m_Version: 0
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedPostProcessingVariantsAndResources: 1
m_StripUnusedVariants: 1
m_StripScreenCoordOverrideVariants: 1
m_Strip2DUnusedVariants: 0
m_ShaderVariantLogLevel: 0
m_ExportShaderVariants: 1
m_StripDebugVariants: 1
@@ -67,9 +68,12 @@ MonoBehaviour:
- rid: 1704570155956699148
- rid: 1704570155956699149
- rid: 1704570155956699150
- rid: 3844770271378276352
- rid: 3844770271378276353
- rid: 3844770271378276354
m_RuntimeSettings:
m_List: []
m_AssetVersion: 10
m_AssetVersion: 11
m_ObsoleteDefaultVolumeProfile: {fileID: 0}
m_RenderingLayerNames:
- Light Layer default
@@ -210,7 +214,7 @@ MonoBehaviour:
version: 1
useReflectionProbeRotation: 0
- rid: 1704570155956699144
type: {class: ScreenSpaceAmbientOcclusionDynamicResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
type: {class: ScreenSpaceAmbientOcclusionBlueNoiseResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_BlueNoise256Textures:
- {fileID: 2800000, guid: 36f118343fc974119bee3d09e2111500, type: 3}
@@ -222,9 +226,9 @@ MonoBehaviour:
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
m_Version: 0
- rid: 1704570155956699145
type: {class: ScreenSpaceAmbientOcclusionPersistentResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
type: {class: ScreenSpaceAmbientOcclusionCoreResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
m_RasterizationShader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
m_Version: 0
- rid: 1704570155956699146
type: {class: URPTerrainShaderSetting, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
@@ -262,6 +266,11 @@ MonoBehaviour:
type: {class: RenderingDebuggerRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
m_version: 0
m_PanelSettings: {fileID: 11400000, guid: fa69697be3070b04a893666f5947f18c, type: 2}
m_StyleSheets:
- {fileID: 7433441132597879392, guid: 0ff99fd36f66f1a41bcc1d3c90e0922a, type: 3}
- {fileID: 7433441132597879392, guid: 3a8aa4d508da46d4dace18b280f064aa, type: 3}
m_VisualTreeAsset: {fileID: 9197481963319205126, guid: b647ceb1e15264943b9b439971e71110, type: 3}
- rid: 1704570155956699149
type: {class: LightmapSamplingSettings, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
data:
@@ -278,13 +287,42 @@ MonoBehaviour:
_skyBoxMesh: {fileID: 4300000, guid: 0529e6c5f6dea8c4a8c2835ed7de57cb, type: 2}
_sixFaceSkyBoxMesh: {fileID: 4300000, guid: a80925ceebd011741b42509226cefc74, type: 2}
_buildLightGridShader: {fileID: 7200000, guid: 16e47c1641bd0104e92b624601457bb0, type: 3}
_solidColorShader: {fileID: 4800000, guid: 3765a7ac691541038de4d587b94ae768, type: 3}
- rid: 3844770271378276352
type: {class: ScreenSpaceReflectionPersistentResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_Shader: {fileID: 4800000, guid: 7b3e6785f5f6b634794df3a85a2a35da, type: 3}
m_BlitShader: {fileID: 4800000, guid: 815c625bb9d4fe240a4ccf42ca3899cb, type: 3}
m_Version: 0
- rid: 3844770271378276353
type: {class: MipGenRenderPipelineRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_ColorPyramidPS: {fileID: 4800000, guid: 63b92baba208e314c8fdebe52ca0cc34, type: 3}
m_ColorPyramidCS: {fileID: 7200000, guid: 28969cfddd9ef3f4e94b971690146a4f, type: 3}
m_DepthPyramidCS: {fileID: 7200000, guid: 90a204702cd44e54cac7ed4fc6e5d86b, type: 3}
- rid: 3844770271378276354
type: {class: UniversalRenderPipelineFilmGrainResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_Textures:
- {fileID: 2800000, guid: 654c582f7f8a5a14dbd7d119cbde215d, type: 3}
- {fileID: 2800000, guid: dd77ffd079630404e879388999033049, type: 3}
- {fileID: 2800000, guid: 1097e90e1306e26439701489f391a6c0, type: 3}
- {fileID: 2800000, guid: f0b67500f7fad3b4c9f2b13e8f41ba6e, type: 3}
- {fileID: 2800000, guid: 9930fb4528622b34687b00bbe6883de7, type: 3}
- {fileID: 2800000, guid: bd9e8c758250ef449a4b4bfaad7a2133, type: 3}
- {fileID: 2800000, guid: 510a2f57334933e4a8dbabe4c30204e4, type: 3}
- {fileID: 2800000, guid: b4db8180660810945bf8d55ab44352ad, type: 3}
- {fileID: 2800000, guid: fd2fd78b392986e42a12df2177d3b89c, type: 3}
- {fileID: 2800000, guid: 5cdee82a77d13994f83b8fdabed7c301, type: 3}
m_Version: 0
- rid: 6852985685364965376
type: {class: URPShaderStrippingSetting, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_Version: 0
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedPostProcessingVariantsAndResources: 1
m_StripUnusedVariants: 1
m_StripScreenCoordOverrideVariants: 1
m_Strip2DUnusedVariants: 0
- rid: 6852985685364965377
type: {class: UniversalRenderPipelineEditorShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
@@ -318,6 +356,7 @@ MonoBehaviour:
m_BlitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
m_CoreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
m_CoreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, type: 3}
m_UIBackdropFilterCompositePS: {fileID: 4800000, guid: 8b3d1e6f4c5a4d219a72f8e1c0b3d4a7, type: 3}
m_SamplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
m_TerrainDetailLit: {fileID: 0}
m_TerrainDetailGrassBillboard: {fileID: 0}
@@ -334,6 +373,7 @@ MonoBehaviour:
data:
m_Version: 0
m_LightShader: {fileID: 4800000, guid: 3f6c848ca3d7bca4bbe846546ac701a1, type: 3}
m_RenderingLayerMaskShader: {fileID: 4800000, guid: 9ac9bae9f40d7dc4a80dbf809b9544aa, type: 3}
m_ProjectedShadowShader: {fileID: 4800000, guid: ce09d4a80b88c5a4eb9768fab4f1ee00, type: 3}
m_SpriteShadowShader: {fileID: 4800000, guid: 44fc62292b65ab04eabcf310e799ccf6, type: 3}
m_SpriteUnshadowShader: {fileID: 4800000, guid: de02b375720b5c445afe83cd483bedf3, type: 3}
@@ -348,6 +388,7 @@ MonoBehaviour:
type: {class: UniversalRenderPipelineEditorMaterials, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
data:
m_DefaultMaterial: {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_SimpleLitMaterial: {fileID: 2100000, guid: 6a1143ee683302f4aa628c052723efc1, type: 2}
m_DefaultParticleMaterial: {fileID: 2100000, guid: e823cd5b5d27c0f4b8256e7c12ee3e6d, type: 2}
m_DefaultLineMaterial: {fileID: 2100000, guid: e823cd5b5d27c0f4b8256e7c12ee3e6d, type: 2}
m_DefaultTerrainMaterial: {fileID: 2100000, guid: 594ea882c5a793440b60ff72d896021e, type: 2}

View File

@@ -1,63 +0,0 @@
{
"version": 1,
"name": "Tangentbord",
"maps": [
{
"name": "MoveUp",
"id": "52b14811-b367-4f32-b6c8-696885a893eb",
"actions": [
{
"name": "New action",
"type": "Button",
"id": "fab289a9-ad4e-4bdc-97e5-b19aa8ffe793",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "",
"id": "2e70d29e-afe5-42b7-969b-abb44886b2e5",
"path": "<Keyboard>/w",
"interactions": "",
"processors": "",
"groups": "",
"action": "New action",
"isComposite": false,
"isPartOfComposite": false
}
]
},
{
"name": "MoveDown",
"id": "c4188819-ef54-4a24-964a-ae22a0f5305f",
"actions": [
{
"name": "New action",
"type": "Button",
"id": "5e3eec9b-2627-4cc5-87fb-4a2c0f109247",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "",
"id": "2f259070-4617-424b-a7d5-03021213f986",
"path": "<Keyboard>/s",
"interactions": "",
"processors": "",
"groups": "",
"action": "New action",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": []
}

View File

@@ -1,14 +0,0 @@
fileFormatVersion: 2
guid: 889411acbee31479da048b699a8c9751
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 0
wrapperCodePath:
wrapperClassName:
wrapperCodeNamespace:

View File

@@ -1,7 +1,10 @@
fileFormatVersion: 2
guid: 7b397333e5a914d45bfa82fc5e36e16b
TextureImporter:
internalIDToNameTable: []
internalIDToNameTable:
- first:
213: -7443756053782179069
second: background_0
externalObjects: {}
serializedVersion: 13
mipmaps:
@@ -53,7 +56,9 @@ TextureImporter:
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationMethod: 0
spriteTessellationDetail: -1
spriteGeometrySubdivision: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
@@ -95,7 +100,29 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
sprites:
- serializedVersion: 2
name: background_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 626
height: 417
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
physicsShape: []
tessellationDetail: -1
bones: []
spriteID: 30356abce4772b890800000000000000
internalID: -7443756053782179069
vertices: []
indices:
edges: []
weights: []
outline: []
customData:
physicsShape: []