From 047073fe8aceb5592bc5c0791841bba443214553 Mon Sep 17 00:00:00 2001 From: JoansLink00 Date: Fri, 23 Jan 2026 14:44:44 +0100 Subject: [PATCH] PlayerMove Blockmove both reset --- .idea/.idea.Codename Penguin/.idea/.gitignore | 15 + .../.idea/encodings.xml | 4 + .../.idea/indexLayout.xml | 8 + .idea/.idea.Codename Penguin/.idea/vcs.xml | 6 + Assets/InputSystem_Actions.inputactions | 1 + Assets/Scenes/SampleScene.unity | 283 +++++++++++++++--- Assets/Scripts.meta | 8 + Assets/Scripts/IceBlockPush.cs | 43 +++ Assets/Scripts/IceBlockPush.cs.meta | 2 + Assets/Scripts/Pit.cs | 17 ++ Assets/Scripts/Pit.cs.meta | 2 + Assets/Scripts/Player.meta | 8 + Assets/Scripts/Player/PlayerMove.cs | 31 ++ Assets/Scripts/Player/PlayerMove.cs.meta | 2 + ProjectSettings/ProjectSettings.asset | 2 +- 15 files changed, 397 insertions(+), 35 deletions(-) create mode 100644 .idea/.idea.Codename Penguin/.idea/.gitignore create mode 100644 .idea/.idea.Codename Penguin/.idea/encodings.xml create mode 100644 .idea/.idea.Codename Penguin/.idea/indexLayout.xml create mode 100644 .idea/.idea.Codename Penguin/.idea/vcs.xml create mode 100644 Assets/Scripts.meta create mode 100644 Assets/Scripts/IceBlockPush.cs create mode 100644 Assets/Scripts/IceBlockPush.cs.meta create mode 100644 Assets/Scripts/Pit.cs create mode 100644 Assets/Scripts/Pit.cs.meta create mode 100644 Assets/Scripts/Player.meta create mode 100644 Assets/Scripts/Player/PlayerMove.cs create mode 100644 Assets/Scripts/Player/PlayerMove.cs.meta diff --git a/.idea/.idea.Codename Penguin/.idea/.gitignore b/.idea/.idea.Codename Penguin/.idea/.gitignore new file mode 100644 index 0000000..b6625cf --- /dev/null +++ b/.idea/.idea.Codename Penguin/.idea/.gitignore @@ -0,0 +1,15 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/contentModel.xml +/modules.xml +/.idea.Codename Penguin.iml +/projectSettingsUpdater.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.Codename Penguin/.idea/encodings.xml b/.idea/.idea.Codename Penguin/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Codename Penguin/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.Codename Penguin/.idea/indexLayout.xml b/.idea/.idea.Codename Penguin/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.Codename Penguin/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Codename Penguin/.idea/vcs.xml b/.idea/.idea.Codename Penguin/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.Codename Penguin/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Assets/InputSystem_Actions.inputactions b/Assets/InputSystem_Actions.inputactions index 1a12cb9..89ea999 100644 --- a/Assets/InputSystem_Actions.inputactions +++ b/Assets/InputSystem_Actions.inputactions @@ -1,4 +1,5 @@ { + "version": 1, "name": "InputSystem_Actions", "maps": [ { diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 177d4ba..f962cd2 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -119,6 +119,183 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &319279591 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 319279597} + - component: {fileID: 319279596} + - component: {fileID: 319279595} + - component: {fileID: 319279594} + - component: {fileID: 319279593} + - component: {fileID: 319279592} + - component: {fileID: 319279598} + m_Layer: 0 + m_Name: IceBlock + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &319279592 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1.1, y: 1.1, z: 1.1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!54 &319279593 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + serializedVersion: 5 + m_Mass: 10 + m_LinearDamping: 0 + m_AngularDamping: 0.05 + m_CenterOfMass: {x: 0, y: 0, z: 0} + m_InertiaTensor: {x: 1, y: 1, z: 1} + m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ImplicitCom: 1 + m_ImplicitTensor: 1 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 112 + m_CollisionDetection: 0 +--- !u!65 &319279594 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &319279595 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_ForceMeshLod: -1 + m_MeshLodSelectionBias: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: -4973734387028869240, guid: 1dbf28c1bb322474d981b2dc555e28b0, type: 3} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_GlobalIlluminationMeshLod: 0 + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_MaskInteraction: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &319279596 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &319279597 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.39, y: 1.51404, z: -0.49877} + m_LocalScale: {x: 2, y: 2, z: 2} + m_ConstrainProportionsScale: 1 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &319279598 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 319279591} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e911d5b3b7fa4494dade3496bff2ee20, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::IceBlockPush + contactForce: 4 + StartPos: {x: 0.39, y: 1.51404, z: -0.49877} --- !u!1 &330585543 GameObject: m_ObjectHideFlags: 0 @@ -179,7 +356,7 @@ Camera: height: 1 near clip plane: 0.3 far clip plane: 1000 - field of view: 60 + field of view: 44.2 orthographic: 0 orthographic size: 5 m_Depth: -1 @@ -205,13 +382,13 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 330585543} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalRotation: {x: 0.55593294, y: 0, z: 0, w: 0.8312272} + m_LocalPosition: {x: 0, y: 30.1, z: -11.65} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 67.55, y: 0, z: 0} --- !u!114 &330585547 MonoBehaviour: m_ObjectHideFlags: 0 @@ -445,7 +622,7 @@ GameObject: - component: {fileID: 955231357} - component: {fileID: 955231356} - component: {fileID: 955231355} - - component: {fileID: 955231354} + - component: {fileID: 955231360} m_Layer: 0 m_Name: Penguin m_TagString: Untagged @@ -453,31 +630,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!143 &955231354 -CharacterController: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 955231353} - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_ProvidesContacts: 0 - m_Enabled: 1 - serializedVersion: 3 - m_Height: 2 - m_Radius: 0.5 - m_SlopeLimit: 45 - m_StepOffset: 0.3 - m_SkinWidth: 0.08 - m_MinMoveDistance: 0.001 - m_Center: {x: 0, y: 0, z: 0} --- !u!54 &955231355 Rigidbody: m_ObjectHideFlags: 0 @@ -501,7 +653,7 @@ Rigidbody: m_ImplicitCom: 1 m_ImplicitTensor: 1 m_UseGravity: 1 - m_IsKinematic: 0 + m_IsKinematic: 1 m_Interpolate: 0 m_Constraints: 116 m_CollisionDetection: 0 @@ -553,7 +705,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} + - {fileID: 2100000, guid: 594ea882c5a793440b60ff72d896021e, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -594,7 +746,68 @@ Transform: m_GameObject: {fileID: 955231353} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.35355, y: 1.23, z: 0} + m_LocalPosition: {x: -15.5, y: 1.23, z: 12.73} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &955231360 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 955231353} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9b9bab48a629093449f53dc5ea63d752, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::PlayerMove + speed: 6 + rb: {fileID: 0} + StartPos: {x: -15.5, y: 1.23, z: 12.73} +--- !u!1 &1604116870 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1604116872} + - component: {fileID: 1604116871} + m_Layer: 0 + m_Name: Pit + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1604116871 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1604116870} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e7c1c3fec0605d746bddf36d1b260908, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::Pit + player: {fileID: 955231360} + ice: {fileID: 319279598} +--- !u!4 &1604116872 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1604116870} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1.78609, y: 0, z: -5.89005} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -720,5 +933,7 @@ SceneRoots: - {fileID: 330585546} - {fileID: 410087041} - {fileID: 832575519} - - {fileID: 955231359} - {fileID: 1736681595} + - {fileID: 955231359} + - {fileID: 319279597} + - {fileID: 1604116872} diff --git a/Assets/Scripts.meta b/Assets/Scripts.meta new file mode 100644 index 0000000..a537fe9 --- /dev/null +++ b/Assets/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 785f855e08bca544bbe413cdafbd9f83 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/IceBlockPush.cs b/Assets/Scripts/IceBlockPush.cs new file mode 100644 index 0000000..8581b06 --- /dev/null +++ b/Assets/Scripts/IceBlockPush.cs @@ -0,0 +1,43 @@ +using System; +using UnityEngine; + +public class IceBlockPush : MonoBehaviour +{ + [SerializeField] float contactForce = 2.5f; + private Rigidbody rb; + [SerializeField] private Vector3 StartPos; + + private void Start() + { + rb = GetComponent(); + } + + private void OnTriggerStay(Collider other) + { + + if (other.GetComponent()) + { + Push(other.transform.position); + } + } + + private void Push(Vector3 position) + { + Vector3 diffrenceVector = rb.transform.position - position; + diffrenceVector.y = 0; + //jetzt Vecort auf rechts,links, oben oder unten + Vector3 directionVector = + Mathf.Abs(diffrenceVector.x) > Mathf.Abs(diffrenceVector.z) + ? new Vector3(Mathf.Sign(diffrenceVector.x), 0, 0) + : new Vector3(0, 0, Mathf.Sign(diffrenceVector.z)); + + //Debug.DrawRay(transform.position, directionVector * 3f, Color.red); + + rb.AddForce(directionVector * contactForce, ForceMode.Impulse); + } + + public void Reset() + { + this.transform.position = StartPos; + } +} diff --git a/Assets/Scripts/IceBlockPush.cs.meta b/Assets/Scripts/IceBlockPush.cs.meta new file mode 100644 index 0000000..fdfcd58 --- /dev/null +++ b/Assets/Scripts/IceBlockPush.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e911d5b3b7fa4494dade3496bff2ee20 \ No newline at end of file diff --git a/Assets/Scripts/Pit.cs b/Assets/Scripts/Pit.cs new file mode 100644 index 0000000..78a0cde --- /dev/null +++ b/Assets/Scripts/Pit.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +public class Pit : MonoBehaviour +{ + public PlayerMove player; + public IceBlockPush ice; + + // Update is called once per frame + void Update() + { + if (Input.GetKeyDown(KeyCode.Space)) + { + player.Reset(); + ice.Reset(); + } + } +} diff --git a/Assets/Scripts/Pit.cs.meta b/Assets/Scripts/Pit.cs.meta new file mode 100644 index 0000000..0f47c74 --- /dev/null +++ b/Assets/Scripts/Pit.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e7c1c3fec0605d746bddf36d1b260908 \ No newline at end of file diff --git a/Assets/Scripts/Player.meta b/Assets/Scripts/Player.meta new file mode 100644 index 0000000..c3f214d --- /dev/null +++ b/Assets/Scripts/Player.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 28852a8ba199cdb458057abc041b9353 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player/PlayerMove.cs b/Assets/Scripts/Player/PlayerMove.cs new file mode 100644 index 0000000..e37e3b3 --- /dev/null +++ b/Assets/Scripts/Player/PlayerMove.cs @@ -0,0 +1,31 @@ +using System; +using UnityEngine; + +public class PlayerMove : MonoBehaviour +{ + [SerializeField] private float speed; + [SerializeField] private Rigidbody rb; + [SerializeField] private Vector3 StartPos; + + private void Start() + { + rb = GetComponent(); + } + + void Update() + { + float horizontalInput = Input.GetAxis("Horizontal"); + float verticalInput = Input.GetAxis("Vertical"); + + Vector3 moveDirection = new Vector3(horizontalInput,0, verticalInput); + moveDirection.Normalize(); + + + transform.Translate(moveDirection * speed * Time.deltaTime, Space.World); + } + + public void Reset() + { + this.transform.position = StartPos; + } +} diff --git a/Assets/Scripts/Player/PlayerMove.cs.meta b/Assets/Scripts/Player/PlayerMove.cs.meta new file mode 100644 index 0000000..b2e013b --- /dev/null +++ b/Assets/Scripts/Player/PlayerMove.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 9b9bab48a629093449f53dc5ea63d752 \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 1a62c0f..a021c65 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -922,7 +922,7 @@ PlayerSettings: qnxGraphicConfPath: apiCompatibilityLevel: 6 captureStartupLogs: {} - activeInputHandler: 1 + activeInputHandler: 2 windowsGamepadBackendHint: 0 cloudProjectId: 6bf7e106-e255-49b6-a4d8-7eac0fd85005 framebufferDepthMemorylessMode: 0