saving progress
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
// MIGHT NOT NEED THIS LOL
|
||||
|
||||
public class WaterBehavior : MonoBehaviour
|
||||
{
|
||||
public Rigidbody2D RB;
|
||||
|
||||
[SerializeField] private float bounceForce = 2;
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col)
|
||||
{
|
||||
Bounce();
|
||||
}
|
||||
|
||||
private void Bounce()
|
||||
{
|
||||
/*RB.velocity = new Vector2(RB.velocity.x, -(RB.velocity.y));
|
||||
RB.AddForce(RB.velocity * bounceForce, ForceMode2D.Impulse);*/
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f11c011d93f67a140b0991fa94ea41c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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()
|
||||
|
||||
@@ -310,6 +310,10 @@ public class PlayerMovement : MonoBehaviour
|
||||
//Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
|
||||
RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
|
||||
}
|
||||
else if (playerBehavior.isInWater)
|
||||
{
|
||||
SetGravityScale(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Default gravity if standing on a platform or moving upwards
|
||||
|
||||
Reference in New Issue
Block a user