mirror of
				https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
				synced 2025-06-27 11:58:51 +02:00 
			
		
		
		
	feat: able to jump on obstacle (#32)
This commit is contained in:
		| @@ -226,6 +226,84 @@ MonoBehaviour: | ||||
|   m_Name:  | ||||
|   m_EditorClassIdentifier:  | ||||
|   playerObject: {fileID: 1267397455} | ||||
| --- !u!1 &634865766 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   serializedVersion: 6 | ||||
|   m_Component: | ||||
|   - component: {fileID: 634865767} | ||||
|   - component: {fileID: 634865768} | ||||
|   m_Layer: 0 | ||||
|   m_Name: ObstacleKiller | ||||
|   m_TagString: Kill | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!4 &634865767 | ||||
| Transform: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 634865766} | ||||
|   serializedVersion: 2 | ||||
|   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||||
|   m_LocalPosition: {x: 0, y: 0, z: 0} | ||||
|   m_LocalScale: {x: 1, y: 1, z: 1} | ||||
|   m_ConstrainProportionsScale: 0 | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 1009490389} | ||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||
| --- !u!61 &634865768 | ||||
| BoxCollider2D: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 634865766} | ||||
|   m_Enabled: 1 | ||||
|   serializedVersion: 3 | ||||
|   m_Density: 1 | ||||
|   m_Material: {fileID: 0} | ||||
|   m_IncludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_ExcludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_LayerOverridePriority: 0 | ||||
|   m_ForceSendLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ForceReceiveLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ContactCaptureLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_CallbackLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_IsTrigger: 0 | ||||
|   m_UsedByEffector: 0 | ||||
|   m_CompositeOperation: 0 | ||||
|   m_CompositeOrder: 0 | ||||
|   m_Offset: {x: -0.0040085316, y: -0.985047} | ||||
|   m_SpriteTilingProperty: | ||||
|     border: {x: 0, y: 0, z: 0, w: 0} | ||||
|     pivot: {x: 0, y: 0} | ||||
|     oldSize: {x: 0, y: 0} | ||||
|     newSize: {x: 0, y: 0} | ||||
|     adaptiveTilingThreshold: 0 | ||||
|     drawMode: 0 | ||||
|     adaptiveTiling: 0 | ||||
|   m_AutoTiling: 0 | ||||
|   m_Size: {x: 5.1211915, y: 2.672097} | ||||
|   m_EdgeRadius: 0 | ||||
| --- !u!1 &725779773 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
| @@ -5059,84 +5137,6 @@ ParticleSystem: | ||||
|         m_PostInfinity: 2 | ||||
|         m_RotationOrder: 4 | ||||
|     vectorLabel1_3: W | ||||
| --- !u!1 &874939977 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   serializedVersion: 6 | ||||
|   m_Component: | ||||
|   - component: {fileID: 874939978} | ||||
|   - component: {fileID: 874939979} | ||||
|   m_Layer: 0 | ||||
|   m_Name: ObstacleSafe | ||||
|   m_TagString: Untagged | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!4 &874939978 | ||||
| Transform: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 874939977} | ||||
|   serializedVersion: 2 | ||||
|   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||||
|   m_LocalPosition: {x: 0, y: 0, z: 0} | ||||
|   m_LocalScale: {x: 1, y: 1, z: 1} | ||||
|   m_ConstrainProportionsScale: 0 | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 1009490389} | ||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||
| --- !u!61 &874939979 | ||||
| BoxCollider2D: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 874939977} | ||||
|   m_Enabled: 1 | ||||
|   serializedVersion: 3 | ||||
|   m_Density: 1 | ||||
|   m_Material: {fileID: 0} | ||||
|   m_IncludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_ExcludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_LayerOverridePriority: 0 | ||||
|   m_ForceSendLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ForceReceiveLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ContactCaptureLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_CallbackLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_IsTrigger: 0 | ||||
|   m_UsedByEffector: 0 | ||||
|   m_CompositeOperation: 0 | ||||
|   m_CompositeOrder: 0 | ||||
|   m_Offset: {x: 0.0044527054, y: 0.00000047683716} | ||||
|   m_SpriteTilingProperty: | ||||
|     border: {x: 0, y: 0, z: 0, w: 0} | ||||
|     pivot: {x: 0, y: 0} | ||||
|     oldSize: {x: 0, y: 0} | ||||
|     newSize: {x: 0, y: 0} | ||||
|     adaptiveTilingThreshold: 0 | ||||
|     drawMode: 0 | ||||
|     adaptiveTiling: 0 | ||||
|   m_AutoTiling: 0 | ||||
|   m_Size: {x: 5.068964, y: 5.1134825} | ||||
|   m_EdgeRadius: 0 | ||||
| --- !u!1 &1009490386 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
| @@ -5218,12 +5218,12 @@ Transform: | ||||
|   m_GameObject: {fileID: 1009490386} | ||||
|   serializedVersion: 2 | ||||
|   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||||
|   m_LocalPosition: {x: -8.41, y: -2.86, z: 0} | ||||
|   m_LocalScale: {x: 0.25, y: 0.25, z: 1} | ||||
|   m_LocalPosition: {x: -6.684, y: -2.897, z: 0} | ||||
|   m_LocalScale: {x: 0.96055, y: 0.2326, z: 1} | ||||
|   m_ConstrainProportionsScale: 0 | ||||
|   m_Children: | ||||
|   - {fileID: 874939978} | ||||
|   - {fileID: 1914709940} | ||||
|   - {fileID: 2006361645} | ||||
|   - {fileID: 634865767} | ||||
|   m_Father: {fileID: 0} | ||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||
| --- !u!1 &1011717286 | ||||
| @@ -5579,10 +5579,9 @@ MonoBehaviour: | ||||
|   m_Name:  | ||||
|   m_EditorClassIdentifier:  | ||||
|   rigidBody: {fileID: 1267397456} | ||||
|   groundObject: {fileID: 1235900592} | ||||
|   initialPosition: {x: 0, y: 0, z: 0} | ||||
|   initialRotation: {x: 0, y: 0, z: 0, w: 0} | ||||
|   playerObject: {fileID: 1267397455} | ||||
|   particle: {fileID: 725779776} | ||||
|   isColliding: 1 | ||||
|   audioSource: {fileID: 1267397461} | ||||
| --- !u!61 &1267397460 | ||||
| BoxCollider2D: | ||||
| @@ -5738,28 +5737,13 @@ GameObject: | ||||
|   - component: {fileID: 1783527216} | ||||
|   - component: {fileID: 1783527215} | ||||
|   - component: {fileID: 1783527214} | ||||
|   - component: {fileID: 1783527213} | ||||
|   m_Layer: 0 | ||||
|   m_Name: Spike | ||||
|   m_TagString: Untagged | ||||
|   m_TagString: Kill | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!114 &1783527213 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 1783527212} | ||||
|   m_Enabled: 1 | ||||
|   m_EditorHideFlags: 0 | ||||
|   m_Script: {fileID: 11500000, guid: 5b6c5b0fa69a1f00da3d8c4aa96485f3, type: 3} | ||||
|   m_Name:  | ||||
|   m_EditorClassIdentifier:  | ||||
|   playerScript: {fileID: 0} | ||||
|   playerObject: {fileID: 1267397455} | ||||
| --- !u!60 &1783527214 | ||||
| PolygonCollider2D: | ||||
|   m_ObjectHideFlags: 0 | ||||
| @@ -5790,7 +5774,7 @@ PolygonCollider2D: | ||||
|   m_CallbackLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_IsTrigger: 1 | ||||
|   m_IsTrigger: 0 | ||||
|   m_UsedByEffector: 0 | ||||
|   m_CompositeOperation: 0 | ||||
|   m_CompositeOrder: 0 | ||||
| @@ -5937,7 +5921,7 @@ Transform: | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 0} | ||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||
| --- !u!1 &1914709939 | ||||
| --- !u!1 &2006361644 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
| @@ -5945,23 +5929,22 @@ GameObject: | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   serializedVersion: 6 | ||||
|   m_Component: | ||||
|   - component: {fileID: 1914709940} | ||||
|   - component: {fileID: 1914709942} | ||||
|   - component: {fileID: 1914709941} | ||||
|   - component: {fileID: 2006361645} | ||||
|   - component: {fileID: 2006361646} | ||||
|   m_Layer: 0 | ||||
|   m_Name: ObstacleKiller | ||||
|   m_Name: ObstacleSafer | ||||
|   m_TagString: Untagged | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!4 &1914709940 | ||||
| --- !u!4 &2006361645 | ||||
| Transform: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 1914709939} | ||||
|   m_GameObject: {fileID: 2006361644} | ||||
|   serializedVersion: 2 | ||||
|   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||||
|   m_LocalPosition: {x: 0, y: 0, z: 0} | ||||
| @@ -5970,28 +5953,13 @@ Transform: | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 1009490389} | ||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||
| --- !u!114 &1914709941 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 1914709939} | ||||
|   m_Enabled: 1 | ||||
|   m_EditorHideFlags: 0 | ||||
|   m_Script: {fileID: 11500000, guid: e105dbba5bf85a944a8270ed72ebd3d2, type: 3} | ||||
|   m_Name:  | ||||
|   m_EditorClassIdentifier:  | ||||
|   playerScript: {fileID: 0} | ||||
|   playerObject: {fileID: 1267397455} | ||||
|   audioSource: {fileID: 0} | ||||
| --- !u!61 &1914709942 | ||||
| --- !u!61 &2006361646 | ||||
| BoxCollider2D: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 1914709939} | ||||
|   m_GameObject: {fileID: 2006361644} | ||||
|   m_Enabled: 1 | ||||
|   serializedVersion: 3 | ||||
|   m_Density: 1 | ||||
| @@ -6015,11 +5983,11 @@ BoxCollider2D: | ||||
|   m_CallbackLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_IsTrigger: 1 | ||||
|   m_IsTrigger: 0 | ||||
|   m_UsedByEffector: 0 | ||||
|   m_CompositeOperation: 0 | ||||
|   m_CompositeOrder: 0 | ||||
|   m_Offset: {x: 0.0000009536743, y: -0.7657876} | ||||
|   m_Offset: {x: -0.004009247, y: 1.7748187} | ||||
|   m_SpriteTilingProperty: | ||||
|     border: {x: 0, y: 0, z: 0, w: 0} | ||||
|     pivot: {x: 0, y: 0} | ||||
| @@ -6029,7 +5997,7 @@ BoxCollider2D: | ||||
|     drawMode: 0 | ||||
|     adaptiveTiling: 0 | ||||
|   m_AutoTiling: 0 | ||||
|   m_Size: {x: 5.0600605, y: 3.5822077} | ||||
|   m_Size: {x: 5.121194, y: 1.4569769} | ||||
|   m_EdgeRadius: 0 | ||||
| --- !u!1660057539 &9223372036854775807 | ||||
| SceneRoots: | ||||
|   | ||||
| @@ -1,25 +0,0 @@ | ||||
| using UnityEngine; | ||||
|  | ||||
| public class Obstacle : MonoBehaviour | ||||
| { | ||||
|     public PlayerScript playerScript; | ||||
|     public GameObject playerObject; | ||||
|     public AudioSource audioSource; | ||||
|  | ||||
|     public void Start() | ||||
|     { | ||||
|         playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>(); | ||||
|     } | ||||
|  | ||||
|     public void Update() | ||||
|     { | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public void OnTriggerEnter2D(Collider2D collision) | ||||
|     { | ||||
|         playerObject.transform.rotation = playerScript.initialRotation; | ||||
|         playerObject.transform.position = playerScript.initialPosition; | ||||
|         playerScript.audioSource.Play(); | ||||
|     } | ||||
| } | ||||
| @@ -1,2 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: e105dbba5bf85a944a8270ed72ebd3d2 | ||||
| @@ -1,27 +1,22 @@ | ||||
| using UnityEngine; | ||||
| using UnityEngine.SceneManagement; | ||||
|  | ||||
| public class PlayerScript : MonoBehaviour | ||||
| { | ||||
|     public Rigidbody2D rigidBody; | ||||
|     public GameObject groundObject; | ||||
|  | ||||
|     public Vector3 initialPosition; | ||||
|     public Quaternion initialRotation; | ||||
|     public GameObject playerObject; | ||||
|  | ||||
|     public ParticleSystem particle; | ||||
|  | ||||
|     private bool wantsToJump = false; | ||||
|     public bool isColliding = true; | ||||
|  | ||||
|     public AudioSource audioSource; | ||||
|  | ||||
|     public void Start() | ||||
|     { | ||||
|         initialPosition = transform.position; | ||||
|         initialRotation = transform.rotation; | ||||
|  | ||||
|         var mainModule = particle.main; | ||||
|         mainModule.simulationSpace = ParticleSystemSimulationSpace.World; | ||||
|  | ||||
|         particle.transform.parent = null; | ||||
|     } | ||||
|  | ||||
| @@ -68,7 +63,7 @@ public class PlayerScript : MonoBehaviour | ||||
|  | ||||
|     private bool IsJumping() | ||||
|     { | ||||
|         return Mathf.Abs(initialPosition.y - transform.position.y) > 0.05f; | ||||
|         return !isColliding; | ||||
|     } | ||||
|  | ||||
|     private void AlignRotation() | ||||
| @@ -89,4 +84,19 @@ public class PlayerScript : MonoBehaviour | ||||
|         var velocityOverLifetime = particle.velocityOverLifetime; | ||||
|         velocityOverLifetime.x = rigidBody.linearVelocity.x; | ||||
|     } | ||||
|  | ||||
|     public void OnCollisionEnter2D(Collision2D collision) | ||||
|     { | ||||
|         isColliding = true; | ||||
|  | ||||
|         if (collision.gameObject.tag == "Kill") | ||||
|         { | ||||
|             SceneManager.LoadScene(SceneManager.GetActiveScene().name); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void OnCollisionExit2D(Collision2D collision) | ||||
|     { | ||||
|         isColliding = false; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,24 +0,0 @@ | ||||
| using UnityEngine; | ||||
|  | ||||
| public class SpikeScript : MonoBehaviour | ||||
| { | ||||
|     public PlayerScript playerScript; | ||||
|     public GameObject playerObject; | ||||
|  | ||||
|     public void Start() | ||||
|     { | ||||
|         playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerScript>(); | ||||
|     } | ||||
|  | ||||
|     public void Update() | ||||
|     { | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public void OnTriggerEnter2D(Collider2D collision) | ||||
|     { | ||||
|         playerObject.transform.rotation = playerScript.initialRotation; | ||||
|         playerObject.transform.position = playerScript.initialPosition; | ||||
|         playerScript.audioSource.Play(); | ||||
|     } | ||||
| } | ||||
| @@ -1,2 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 5b6c5b0fa69a1f00da3d8c4aa96485f3 | ||||
| @@ -3,7 +3,8 @@ | ||||
| --- !u!78 &1 | ||||
| TagManager: | ||||
|   serializedVersion: 3 | ||||
|   tags: [] | ||||
|   tags: | ||||
|   - Kill | ||||
|   layers: | ||||
|   - Default | ||||
|   - TransparentFX | ||||
|   | ||||
		Reference in New Issue
	
	Block a user