diff --git a/Assets/Physic_Materials/Slippery.physicsMaterial2D b/Assets/Physic_Materials/Slippery.physicsMaterial2D index e78ea10..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.9 + bounciness: 1 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 33010fb..e8f1ca6 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -151,9 +151,131 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 2103537546} + - {fileID: 342133042} m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &342133041 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 342133042} + - component: {fileID: 342133043} + - component: {fileID: 342133045} + - component: {fileID: 342133044} + m_Layer: 3 + m_Name: Circle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &342133042 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 342133041} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 15.09, y: 5, z: 0.70835644} + m_LocalScale: {x: 4, y: 4, z: 1} + m_Children: [] + m_Father: {fileID: 8146526} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &342133043 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 342133041} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + 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: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: -2413806693520163455, guid: ebe73ca9363db456bacf42c025bb4847, type: 3} + m_Color: {r: 1, g: 0, b: 0.14096355, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!50 &342133044 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 342133041} + m_BodyType: 2 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!58 &342133045 +CircleCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 342133041} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + serializedVersion: 2 + m_Radius: 0.5 --- !u!1 &519420028 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CharacterController2D.cs b/Assets/Scripts/CharacterController2D.cs index 9c42e16..a3c2643 100644 --- a/Assets/Scripts/CharacterController2D.cs +++ b/Assets/Scripts/CharacterController2D.cs @@ -3,7 +3,7 @@ using UnityEngine.Events; public class CharacterController2D : MonoBehaviour { - [SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps. + public float m_JumpForce = 400f; // Amount of force added when the player jumps. [Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement [SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping; [SerializeField] private LayerMask m_WhatIsGround; // A mask determining what is ground to the character diff --git a/Assets/Scripts/PlayerControls.cs b/Assets/Scripts/PlayerControls.cs index 3e55ac4..d98b2ee 100644 --- a/Assets/Scripts/PlayerControls.cs +++ b/Assets/Scripts/PlayerControls.cs @@ -12,6 +12,7 @@ public class PlayerControls : MonoBehaviour public CharacterController2D controller; public float runspeed = 40f; float horizonatalaxis = 0f; + bool jumping = false; bool switchy = false; @@ -30,16 +31,19 @@ public class PlayerControls : MonoBehaviour if(Input.GetButtonDown("Switch")) { switchy = !switchy; + if (switchy){ + sprite.flipY = true; + rigidbody.sharedMaterial = top; + controller.m_JumpForce = controller.m_JumpForce * 1.2f; + } + else { + sprite.flipY = false; + rigidbody.sharedMaterial = bottom; + controller.m_JumpForce = controller.m_JumpForce * 0.8f; + } } - if (switchy){ - sprite.flipY = true; - rigidbody.sharedMaterial = top; - } - else { - sprite.flipY = false; - rigidbody.sharedMaterial = bottom; - } + } void FixedUpdate(){