diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity
index 68d1cfa..f4ddda9 100644
--- a/Assets/Scenes/GameScene.unity
+++ b/Assets/Scenes/GameScene.unity
@@ -1055,6 +1055,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
speed: 3
+ jumpPower: 6
groundLayer:
serializedVersion: 2
m_Bits: 256
diff --git a/Assets/Scripts/Parallax/ParallaxCamera.cs b/Assets/Scripts/Parallax/ParallaxCamera.cs
index 77ec5a5..b7fcc4a 100644
--- a/Assets/Scripts/Parallax/ParallaxCamera.cs
+++ b/Assets/Scripts/Parallax/ParallaxCamera.cs
@@ -3,7 +3,6 @@ using UnityEngine;
///
/// Link zum OG Script: https://pastebin.com/jD62XeKQ
///
-///
public class ParallaxCamera : MonoBehaviour
{
// delegate -> type; safely encapsulate a method
diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs
index c690058..c632bc5 100644
--- a/Assets/Scripts/PlayerMovement.cs
+++ b/Assets/Scripts/PlayerMovement.cs
@@ -1,15 +1,21 @@
using Unity.VisualScripting.FullSerializer;
+using UnityEditor.Experimental.GraphView;
using UnityEngine;
+///
+/// Playermovement, sowie Animation usw. hier angeschaut: https://www.youtube.com/playlist?list=PLgOEwFbvGm5o8hayFB6skAfa8Z-mw4dPV
+///
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float speed;
+ [SerializeField] private float jumpPower;
[SerializeField] private LayerMask groundLayer;
[SerializeField] private LayerMask wallLayer;
private Rigidbody2D body;
private Animator anim;
private BoxCollider2D boxCollider;
private float wallJumpCooldown;
+ private float horizontalInput;
private void Awake()
{
@@ -21,7 +27,7 @@ public class PlayerMovement : MonoBehaviour
private void Update()
{
- float horizontalInput = Input.GetAxis("Horizontal");
+ horizontalInput = Input.GetAxis("Horizontal");
// move
body.velocity = new Vector2(horizontalInput * speed, body.velocity.y);
@@ -37,13 +43,8 @@ public class PlayerMovement : MonoBehaviour
}
// wall jump logic
- if (wallJumpCooldown < 0.2f)
+ if (wallJumpCooldown > 0.2f)
{
- if (Input.GetKey(KeyCode.W) && isGrounded())
- {
- Jump();
- }
-
body.velocity = new Vector2(horizontalInput * speed, body.velocity.y);
if (onWall() && !isGrounded())
@@ -51,18 +52,48 @@ public class PlayerMovement : MonoBehaviour
body.gravityScale = 0;
body.velocity = Vector2.zero;
}
+ else
+ {
+ body.gravityScale = 2;
+ }
+
+ if (Input.GetKey(KeyCode.W))
+ {
+ Jump();
+ }
+ }
+ // jumpwall cd
+ else
+ {
+ wallJumpCooldown += Time.deltaTime;
}
// set animator parameters
anim.SetBool("run", horizontalInput != 0);
- anim.SetBool("grounded", isGrounded());
-
+ anim.SetBool("grounded", isGrounded());
}
private void Jump()
{
- body.velocity = new Vector2(body.velocity.x, speed);
- anim.SetTrigger("jump");
+ if (isGrounded())
+ {
+ body.velocity = new Vector2(body.velocity.x, jumpPower);
+ anim.SetTrigger("jump");
+ }
+ // "climb" on wall
+ else if (onWall() && !isGrounded())
+ {
+ if (horizontalInput == 0)
+ {
+ body.velocity = new Vector2(-Mathf.Sign(transform.localScale.x) * 9, 0);
+ transform.localScale = new Vector3(-Mathf.Sign(transform.localScale.x), transform.localScale.y, transform.localScale.z);
+ }
+ else
+ {
+ body.velocity = new Vector2(-Mathf.Sign(transform.localScale.x) * 3, 6);
+ }
+ wallJumpCooldown = 0;
+ }
}
private void OnCollisionEnter2D(Collision2D collision)