saving progress
This commit is contained in:
@@ -25,6 +25,9 @@ public class PlayerBehavior : MonoBehaviour
|
||||
public float dashDistance = 0.1f;
|
||||
private float currentDashTime;
|
||||
public bool isDash = false;
|
||||
public float bonk = 2f;
|
||||
private Vector2 saveVelocity;
|
||||
public bool isInWater = false;
|
||||
|
||||
[Header("Grappling:")]
|
||||
[SerializeField] public Tutorial_GrapplingGun grapplingGun;
|
||||
@@ -112,7 +115,6 @@ public class PlayerBehavior : MonoBehaviour
|
||||
}
|
||||
transform.position = transform.position + moveDirection;
|
||||
currentDashTime += dashStopSpeed;
|
||||
print("cdt " + currentDashTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -224,9 +226,28 @@ public class PlayerBehavior : MonoBehaviour
|
||||
|
||||
void Bounce()
|
||||
{
|
||||
Vector2 reflect = new Vector2(-(saveVelocity.x),-(saveVelocity.y) * bonk);
|
||||
print("x vel: " + saveVelocity.x);
|
||||
print("y vel: " + saveVelocity.y);
|
||||
_rb.AddForce(reflect, ForceMode2D.Impulse);
|
||||
print("boing");
|
||||
}
|
||||
|
||||
void Water()
|
||||
{
|
||||
if(_rb.velocity.y < 0.2f)
|
||||
{
|
||||
saveVelocity = Vector2.zero;
|
||||
isInWater = true;
|
||||
print("buoy");
|
||||
}
|
||||
else
|
||||
{
|
||||
saveVelocity = _rb.velocity;
|
||||
//_rb.AddForce(saveVelocity, ForceMode2D.Force);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D col)
|
||||
{
|
||||
if (col.tag == "grappleSurface")
|
||||
@@ -248,9 +269,9 @@ public class PlayerBehavior : MonoBehaviour
|
||||
this.playerController.in_range = true;
|
||||
this.playerController.enemy = col.transform.parent.gameObject;
|
||||
}
|
||||
else if (col.tag == "bouncy")
|
||||
else if (col.tag == "water")
|
||||
{
|
||||
Bounce();
|
||||
Water();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +286,10 @@ public class PlayerBehavior : MonoBehaviour
|
||||
this.playerController.in_range = false;
|
||||
this.playerController.enemy = null;
|
||||
}
|
||||
else if (col.tag == "water")
|
||||
{
|
||||
isInWater = false;
|
||||
}
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D collision)
|
||||
@@ -296,6 +321,10 @@ public class PlayerBehavior : MonoBehaviour
|
||||
{
|
||||
StateController.Instance.RespawnPlayer();
|
||||
}
|
||||
else if (collision.gameObject.tag == "bouncy")
|
||||
{
|
||||
Bounce();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator DestroyPlayer()
|
||||
|
||||
Reference in New Issue
Block a user