diff --git a/Assets/Prefabs/Ground.prefab b/Assets/Prefabs/Ground.prefab index e41baa8..854834a 100644 --- a/Assets/Prefabs/Ground.prefab +++ b/Assets/Prefabs/Ground.prefab @@ -10,7 +10,7 @@ GameObject: - 4: {fileID: 417046} - 212: {fileID: 21285978} - 61: {fileID: 6117568} - m_Layer: 0 + m_Layer: 8 m_Name: Ground m_TagString: Untagged m_Icon: {fileID: 0} @@ -74,7 +74,11 @@ Prefab: serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} - m_Modifications: [] + m_Modifications: + - target: {fileID: 0} + propertyPath: m_Layer + value: 8 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 167312} diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 6421b47..e0024f5 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -1,5 +1,20 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &137562 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 430186} + m_Layer: 0 + m_Name: GroundCheck + m_TagString: Untagged + m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &177424 GameObject: m_ObjectHideFlags: 0 @@ -8,8 +23,8 @@ GameObject: serializedVersion: 4 m_Component: - 4: {fileID: 437628} - m_Layer: 8 - m_Name: GroundCheck + m_Layer: 0 + m_Name: WallCheck m_TagString: Untagged m_Icon: {fileID: 5132851093641282708, guid: 0000000000000000d000000000000000, type: 0} m_NavMeshLayer: 0 @@ -32,13 +47,25 @@ GameObject: - 114: {fileID: 11472154} - 114: {fileID: 11478382} - 114: {fileID: 11485758} - m_Layer: 8 + m_Layer: 0 m_Name: Player m_TagString: Player m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!4 &430186 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 137562} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: -.116999999, z: 0} + m_LocalScale: {x: .922599614, y: .922599435, z: .922599435} + m_Children: [] + m_Father: {fileID: 462904} + m_RootOrder: 0 --- !u!4 &437628 Transform: m_ObjectHideFlags: 1 @@ -46,11 +73,11 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 177424} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -.116999999, z: 0} - m_LocalScale: {x: .922599614, y: .922599435, z: .922599435} + m_LocalPosition: {x: .0854000002, y: .0140000004, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 462904} - m_RootOrder: 0 + m_RootOrder: 1 --- !u!4 &462904 Transform: m_ObjectHideFlags: 1 @@ -61,6 +88,7 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: + - {fileID: 430186} - {fileID: 437628} m_Father: {fileID: 0} m_RootOrder: 0 @@ -137,11 +165,14 @@ MonoBehaviour: m_EditorClassIdentifier: maxSpeed: 2 grounded: 1 - groundCheck: {fileID: 437628} + groundCheck: {fileID: 430186} + wallCheck: {fileID: 437628} + groundRadius: .00999999978 + wallCheckRadius: .00999999978 ground: serializedVersion: 2 - m_Bits: 4294967039 - jumpForce: 35 + m_Bits: 256 + jumpForce: 175 --- !u!114 &11472154 MonoBehaviour: m_ObjectHideFlags: 1 @@ -217,6 +248,22 @@ Prefab: propertyPath: bomb value: objectReference: {fileID: 172872, guid: c08879c52df47d54aa37a52cd902cc42, type: 2} + - target: {fileID: 0} + propertyPath: jumpForce + value: 175 + objectReference: {fileID: 0} + - target: {fileID: 0} + propertyPath: ground.m_Bits + value: 256 + objectReference: {fileID: 0} + - target: {fileID: 0} + propertyPath: m_Layer + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 0} + propertyPath: m_Interpolate + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 197158} diff --git a/Assets/Scenes/AlexandreScene.unity b/Assets/Scenes/AlexandreScene.unity index d8f3daf..00a05b6 100644 --- a/Assets/Scenes/AlexandreScene.unity +++ b/Assets/Scenes/AlexandreScene.unity @@ -112,6 +112,7 @@ Transform: m_Children: - {fileID: 1903720196} - {fileID: 1747148540} + - {fileID: 1077673240} m_Father: {fileID: 0} m_RootOrder: 3 --- !u!1 &328141749 @@ -163,7 +164,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 328141749} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 6.75, y: -.280000001, z: 0} + m_LocalPosition: {x: 6.89699984, y: -.298000008, z: 0} m_LocalScale: {x: 1.66666663, y: 1.66666663, z: 1} m_Children: [] m_Father: {fileID: 645992365} @@ -245,41 +246,45 @@ Prefab: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_LocalRotation.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_LocalRotation.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_LocalRotation.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 434640, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} + - target: {fileID: 462904, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} propertyPath: m_RootOrder value: 2 objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: b7819e17682d74b45a71d6831a413e0b, type: 2} m_IsPrefabParent: 0 +--- !u!4 &1077673240 stripped +Transform: + m_PrefabParentObject: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + m_PrefabInternal: {fileID: 1931418958} --- !u!1 &1449410197 GameObject: m_ObjectHideFlags: 0 @@ -387,6 +392,52 @@ Transform: Transform: m_PrefabParentObject: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} m_PrefabInternal: {fileID: 849444827} +--- !u!1001 &1931418958 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 42885627} + m_Modifications: + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_LocalPosition.x + value: -1.29499996 + objectReference: {fileID: 0} + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_LocalPosition.y + value: .768999994 + objectReference: {fileID: 0} + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_LocalRotation.z + value: .707106829 + objectReference: {fileID: 0} + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_LocalRotation.w + value: .707106709 + objectReference: {fileID: 0} + - target: {fileID: 417046, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 167312, guid: 6a21797441b99c942915e70c461edf77, type: 2} + propertyPath: m_Name + value: Ground + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 6a21797441b99c942915e70c461edf77, type: 2} + m_IsPrefabParent: 0 --- !u!1001 &2106831666 Prefab: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/PlayerBehavior.cs b/Assets/Scripts/PlayerBehavior.cs index 4b31553..a8e6f94 100644 --- a/Assets/Scripts/PlayerBehavior.cs +++ b/Assets/Scripts/PlayerBehavior.cs @@ -9,7 +9,9 @@ public class PlayerBehavior : MonoBehaviour // Jump Stuff public bool grounded = true; public Transform groundCheck; - private float groundRadius = 0.1f; + public Transform wallCheck; + public float groundRadius = 0.01f; + public float wallCheckRadius = 0.01f; public LayerMask ground; public float jumpForce = 7.0f; @@ -28,7 +30,7 @@ public class PlayerBehavior : MonoBehaviour // Update is called once per frame void Update() { - if (grounded && Input.GetAxis("Vertical") > 0.0f) + if (grounded && Input.GetButtonDown("Jump")) { anim.SetBool("Ground", false); rb.AddForce(new Vector2(0, jumpForce)); @@ -53,6 +55,11 @@ public class PlayerBehavior : MonoBehaviour anim.SetFloat("vSpeed", rb.velocity.y); float xMove = Input.GetAxis("Horizontal"); + if(Physics2D.OverlapCircle(wallCheck.position, wallCheckRadius, ground)) + { + if((xMove > 0 && facingRight) || (xMove < 0 && !facingRight)) + xMove = 0; + } rb.velocity = new Vector2(xMove * maxSpeed, rb.velocity.y); if ((xMove < 0 && facingRight) || (xMove > 0 && !facingRight)) diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index ab46244..9a51b1b 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -15,7 +15,7 @@ TagManager: - UI - - - - + - Ground - - -