Fixed walljumping, finalized shrink logic

main
thoopchuk26 5 years ago
parent a3ddcba214
commit ec94002a7e

@ -144,7 +144,14 @@ public class GameManager : MonoBehaviour
if (obtainedPowerups.Contains(Powerup.Shrink))
{
if (Input.GetKeyDown("2") && !player.GetComponent<Shrink>().isShrunk)
{
player.GetComponent<Shrink>().startShrinking();
}
if (Input.GetKeyDown("2") && player.GetComponent<Shrink>().isShrunk)
{
player.GetComponent<Shrink>().startUnShrinking();
}
}
}

@ -5,9 +5,8 @@ using UnityEngine;
public class Shrink : MonoBehaviour
{
private GameObject player;
private CapsuleCollider2D hitbox;
private bool canShrink = false;
private float timer = 0;
private bool canUnShrink = true;
public bool isShrunk = true;
// Start is called before the first frame update
void Start()
{
@ -17,12 +16,12 @@ public class Shrink : MonoBehaviour
// Update is called once per frame
void Update()
{
timer += Time.deltaTime;
}
public void startShrinking()
{
if (canShrink)
if (canUnShrink)
{
for(int i = 0; i < 3; i++)
{
@ -35,7 +34,7 @@ public class Shrink : MonoBehaviour
public void startUnShrinking()
{
if (canShrink)
if (canUnShrink)
{
for(int i = 0; i<3; i++)
{
@ -48,11 +47,11 @@ public class Shrink : MonoBehaviour
private void OnTriggerEnter2D(Collider2D collision)
{
canShrink = false;
canUnShrink = false;
}
private void OnTriggerExit2D(Collider2D collision)
{
canShrink = true;
canUnShrink = true;
}
}

@ -125,9 +125,12 @@ public class movement : MonoBehaviour
private void OnCollisionEnter2D(Collision2D collision)
{
numJumps = maxJumps;
isGrounded = true;
Debug.Log("Able to Jump");
if(collision.gameObject.tag == "Floor")
{
numJumps = maxJumps;
isGrounded = true;
Debug.Log("Able to Jump");
}
}
private void JumpAnimation()

Loading…
Cancel
Save