From 97597b483d265a0e8c0c318f79c6a9b7db5ad25b Mon Sep 17 00:00:00 2001 From: BRNSystems Date: Thu, 22 Jul 2021 13:43:40 +0200 Subject: [PATCH] garbage --- Assets/Scenes/Level4.unity | 8 ++-- Assets/Scenes/Tutorial.unity | 7 +--- Assets/Scripts/CharacterController2D.cs | 49 +++++-------------------- Assets/Scripts/PlayerControls.cs | 4 +- UserSettings/EditorUserSettings.asset | 17 +++++---- 5 files changed, 26 insertions(+), 59 deletions(-) diff --git a/Assets/Scenes/Level4.unity b/Assets/Scenes/Level4.unity index 005602b..39b5b4b 100644 --- a/Assets/Scenes/Level4.unity +++ b/Assets/Scenes/Level4.unity @@ -6283,7 +6283,7 @@ Camera: far clip plane: 1000 field of view: 60 orthographic: 1 - orthographic size: 13.65243 + orthographic size: 14 m_Depth: -1 m_CullingMask: serializedVersion: 2 @@ -6768,7 +6768,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 737155566} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 176, y: 14.4, z: 92.19983} + m_LocalPosition: {x: 143.4, y: 14.4, z: 92.19983} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 998253299} @@ -6819,7 +6819,7 @@ SpriteRenderer: m_FlipX: 0 m_FlipY: 0 m_DrawMode: 2 - m_Size: {x: 320, y: 400} + m_Size: {x: 400, y: 500} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 @@ -22475,7 +22475,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1232501489} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 179, y: -23, z: 2.1998286} + m_LocalPosition: {x: 156, y: 45, z: 2.1998286} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 998253299} diff --git a/Assets/Scenes/Tutorial.unity b/Assets/Scenes/Tutorial.unity index 8da8df4..adfa8d5 100644 --- a/Assets/Scenes/Tutorial.unity +++ b/Assets/Scenes/Tutorial.unity @@ -264,18 +264,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8057fdb619b42d94390909e7bc867d87, type: 3} m_Name: m_EditorClassIdentifier: - m_JumpForce: 500 + m_JumpForce: 20 SFX: {fileID: 517709047} JumpSFX: {fileID: 8300000, guid: 437cbeaabc4a81e4e917fb190ecc096c, type: 3} - m_MovementSmoothing: 0.05 - m_AirControl: 1 m_WhatIsGround: serializedVersion: 2 m_Bits: 8 m_GroundCheck: {fileID: 1909349660} - OnLandEvent: - m_PersistentCalls: - m_Calls: [] --- !u!114 &4766649 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CharacterController2D.cs b/Assets/Scripts/CharacterController2D.cs index e51a6b2..7295d01 100644 --- a/Assets/Scripts/CharacterController2D.cs +++ b/Assets/Scripts/CharacterController2D.cs @@ -7,11 +7,8 @@ public class CharacterController2D : MonoBehaviour public AudioSource SFX; public AudioClip JumpSFX; - - [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 - [SerializeField] private Transform m_GroundCheck; // A position marking where to check if the player is grounded. + public LayerMask m_WhatIsGround; // A mask determining what is ground to the character + public Transform m_GroundCheck; // A position marking where to check if the player is grounded. const float k_GroundedRadius = .2f; // Radius of the overlap circle to determine if grounded private bool m_Grounded; // Whether or not the player is grounded. @@ -20,25 +17,14 @@ public class CharacterController2D : MonoBehaviour private bool m_FacingRight = true; // For determining which way the player is currently facing. private Vector3 m_Velocity = Vector3.zero; - [Header("Events")] - [Space] - - public UnityEvent OnLandEvent; - - [System.Serializable] - public class BoolEvent : UnityEvent { } - private void Awake() { m_Rigidbody2D = GetComponent(); - if (OnLandEvent == null) - OnLandEvent = new UnityEvent(); } private void FixedUpdate() { - bool wasGrounded = m_Grounded; m_Grounded = false; // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground @@ -49,8 +35,6 @@ public class CharacterController2D : MonoBehaviour if (colliders[i].gameObject != gameObject) { m_Grounded = true; - if (!wasGrounded) - OnLandEvent.Invoke(); } } } @@ -59,34 +43,19 @@ public class CharacterController2D : MonoBehaviour public void Move(float move, bool jump) { - //only control the player if grounded or airControl is turned on - if (m_Grounded || m_AirControl) - { + // Move the character by finding the target velocity - // Move the character by finding the target velocity - Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y); - // And then smoothing it out and applying it to the character - m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing); + Vector3 targetVelocity = m_Rigidbody2D.velocity; + targetVelocity[0] = move * 10f; + m_Rigidbody2D.velocity = targetVelocity; - // If the input is moving the player right and the player is facing left... - if (move > 0 && !m_FacingRight) - { - // ... flip the player. - //Flip(); - } - // Otherwise if the input is moving the player left and the player is facing right... - else if (move < 0 && m_FacingRight) - { - // ... flip the player. - //Flip(); - } - } // If the player should jump... if (m_Grounded && jump) { - // Add a vertical force to the player. m_Grounded = false; - m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); + targetVelocity = m_Rigidbody2D.velocity; + targetVelocity[1] = m_JumpForce; + m_Rigidbody2D.velocity = targetVelocity; SFX.clip = JumpSFX; SFX.Play(); } diff --git a/Assets/Scripts/PlayerControls.cs b/Assets/Scripts/PlayerControls.cs index 6106ae9..031bd86 100644 --- a/Assets/Scripts/PlayerControls.cs +++ b/Assets/Scripts/PlayerControls.cs @@ -35,12 +35,12 @@ public class PlayerControls : MonoBehaviour if (switchy){ sprite.flipY = true; rb.sharedMaterial = top; - controller.m_JumpForce = controller.m_JumpForce * 1.6f; + controller.m_JumpForce = controller.m_JumpForce * 2f; } else { sprite.flipY = false; rb.sharedMaterial = bottom; - controller.m_JumpForce = controller.m_JumpForce / 1.6f; + controller.m_JumpForce = controller.m_JumpForce / 2f; } sfx.clip = RotateSFX; sfx.Play(); diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 36030b4..fa16c6d 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -9,25 +9,28 @@ EditorUserSettings: value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d flags: 0 RecentlyUsedScenePath-1: - value: 22424703114646680e0b0227036c73150012147f623d28393930 + value: 22424703114646680e0b0227036c731500121478623d28393930 flags: 0 RecentlyUsedScenePath-2: value: 22424703114646680e0b0227036c7919181e0b22623d28393930 flags: 0 RecentlyUsedScenePath-3: - value: 22424703114646680e0b0227036c73150012147b623d28393930 - flags: 0 - RecentlyUsedScenePath-4: value: 22424703114646680e0b0227036c731500121479623d28393930 flags: 0 + RecentlyUsedScenePath-4: + value: 22424703114646680e0b0227036c73150012147c623d28393930 + flags: 0 RecentlyUsedScenePath-5: - value: 22424703114646680e0b0227036c731500121478623d28393930 + value: 22424703114646680e0b0227036c73150012147f623d28393930 flags: 0 RecentlyUsedScenePath-6: - value: 22424703114646680e0b0227036c6b0502180a232d2468252320092a + value: 22424703114646680e0b0227036c73150012147e623d28393930 flags: 0 RecentlyUsedScenePath-7: - value: 22424703114646680e0b0227036c73150012147e623d28393930 + value: 22424703114646680e0b0227036c73150012147b623d28393930 + flags: 0 + RecentlyUsedScenePath-8: + value: 22424703114646680e0b0227036c6b0502180a232d2468252320092a flags: 0 UnityRemoteCompression: value: 337f73