diff --git a/Assets/Physic_Materials/Slippery.physicsMaterial2D b/Assets/Physic_Materials/Slippery.physicsMaterial2D index bac3a00..fa6ae07 100644 --- a/Assets/Physic_Materials/Slippery.physicsMaterial2D +++ b/Assets/Physic_Materials/Slippery.physicsMaterial2D @@ -8,4 +8,4 @@ PhysicsMaterial2D: m_PrefabAsset: {fileID: 0} m_Name: Slippery friction: 0 - bounciness: 0 + bounciness: 1 diff --git a/Assets/Physic_Materials/XNSlippery.physicsMaterial2D b/Assets/Physic_Materials/XNSlippery.physicsMaterial2D new file mode 100644 index 0000000..059863f --- /dev/null +++ b/Assets/Physic_Materials/XNSlippery.physicsMaterial2D @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!62 &6200000 +PhysicsMaterial2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: XNSlippery + friction: 1 + bounciness: 0 diff --git a/Assets/Physic_Materials/XNSlippery.physicsMaterial2D.meta b/Assets/Physic_Materials/XNSlippery.physicsMaterial2D.meta new file mode 100644 index 0000000..6032155 --- /dev/null +++ b/Assets/Physic_Materials/XNSlippery.physicsMaterial2D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c0538ecede9d3b43867ca45f72ba04b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 6200000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 24d20b1..64f08b3 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -291,9 +291,9 @@ GameObject: m_Component: - component: {fileID: 1174924377} - component: {fileID: 1174924376} - - component: {fileID: 1174924375} - component: {fileID: 1174924384} - component: {fileID: 1174924383} + - component: {fileID: 1174924375} - component: {fileID: 1174924382} - component: {fileID: 1174924381} - component: {fileID: 1174924380} @@ -401,7 +401,7 @@ CapsuleCollider2D: m_GameObject: {fileID: 1174924374} m_Enabled: 1 m_Density: 1 - m_Material: {fileID: 0} + m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2} m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -417,7 +417,7 @@ CircleCollider2D: m_GameObject: {fileID: 1174924374} m_Enabled: 1 m_Density: 1 - m_Material: {fileID: 0} + m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2} m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -433,7 +433,7 @@ CircleCollider2D: m_GameObject: {fileID: 1174924374} m_Enabled: 1 m_Density: 1 - m_Material: {fileID: 0} + m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2} m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -449,7 +449,7 @@ CircleCollider2D: m_GameObject: {fileID: 1174924374} m_Enabled: 1 m_Density: 1 - m_Material: {fileID: 0} + m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2} m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 @@ -472,9 +472,9 @@ Rigidbody2D: m_LinearDrag: 0 m_AngularDrag: 0.05 m_GravityScale: 4 - m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2} + m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2} m_Interpolate: 0 - m_SleepingMode: 1 + m_SleepingMode: 0 m_CollisionDetection: 1 m_Constraints: 4 --- !u!114 &1174924383 @@ -490,7 +490,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_JumpForce: 700 - m_CrouchSpeed: 0.36 + m_CrouchSpeed: 1 m_MovementSmoothing: 0.05 m_AirControl: 1 m_WhatIsGround: @@ -498,7 +498,7 @@ MonoBehaviour: m_Bits: 8 m_GroundCheck: {fileID: 1880458412} m_CeilingCheck: {fileID: 599368085} - m_CrouchDisableCollider: {fileID: 1174924378} + m_CrouchDisableCollider: {fileID: 0} OnLandEvent: m_PersistentCalls: m_Calls: [] @@ -530,6 +530,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: animator: {fileID: 1174924375} + top: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2} + rigidbody: {fileID: 1174924382} + bottom: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2} controller: {fileID: 1174924383} runspeed: 40 --- !u!1 &1880458411 @@ -662,7 +665,7 @@ Rigidbody2D: m_LinearDrag: 0 m_AngularDrag: 0.05 m_GravityScale: 1 - m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2} + m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2} m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 @@ -676,7 +679,7 @@ BoxCollider2D: m_GameObject: {fileID: 2103537544} m_Enabled: 1 m_Density: 1 - m_Material: {fileID: 6200000, guid: 1431532fb1c75214a9a8c9b1199fe80b, type: 2} + m_Material: {fileID: 6200000, guid: 2c0538ecede9d3b43867ca45f72ba04b, type: 2} m_IsTrigger: 0 m_UsedByEffector: 0 m_UsedByComposite: 0 diff --git a/Assets/Scripts/PlayerControls.cs b/Assets/Scripts/PlayerControls.cs index 8b21569..f566a4d 100644 --- a/Assets/Scripts/PlayerControls.cs +++ b/Assets/Scripts/PlayerControls.cs @@ -5,11 +5,16 @@ using UnityEngine; public class PlayerControls : MonoBehaviour { public Animator animator; + public PhysicsMaterial2D top; + public Rigidbody2D rigidbody; + public PhysicsMaterial2D bottom; public CharacterController2D controller; public float runspeed = 40f; float horizonatalaxis = 0f; bool jumping = false; bool crouching = false; + bool switchy = false; + void Start() { @@ -23,14 +28,23 @@ public class PlayerControls : MonoBehaviour jumping = Input.GetButton("Jump") || Input.GetAxisRaw("Vertical") > 0; crouching = Input.GetButton("Crouch") || Input.GetAxisRaw("Vertical") < 0; animator.SetFloat("Horizontal_speed", horizonatalaxis); + switchy = Input.GetButton("Switch"); + if (switchy){ + transform.rotation = new Quaternion(0f, 0f, 180f, 0f); + rigidbody.sharedMaterial = top; + } + else { + transform.rotation = new Quaternion(0f, 0f, 0f, 0f); + rigidbody.sharedMaterial = bottom; + } } public void crouchingx(bool stat){ - animator.SetBool("Crouching", stat); + //animator.SetBool("Crouching", stat); } void FixedUpdate(){ - controller.Move(horizonatalaxis * runspeed * Time.fixedDeltaTime, crouching, jumping); + controller.Move(horizonatalaxis * runspeed * Time.fixedDeltaTime, false, jumping); } } diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index a3c867d..ff328fe 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -69,6 +69,22 @@ InputManager: type: 0 axis: 0 joyNum: 0 + - serializedVersion: 3 + m_Name: Switch + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: e + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 - serializedVersion: 3 m_Name: Mouse X descriptiveName: