Commit 9b0cbc77 authored by Andrew Van Buren's avatar Andrew Van Buren

Merge branch 'master' of git.gmu.edu:gadig/birb into implementation_temp

parents 68249535 0d548c07
......@@ -35,8 +35,6 @@ public class BaseEnemy : MonoBehaviour {
{
RaycastHit2D hitSide = Physics2D.Raycast(collisionPos, dir, .1f);
RaycastHit2D hitDown = Physics2D.Raycast(collisionPos, -transform.up, .1f);
Debug.DrawRay(collisionPos, dir, Color.red);
Debug.DrawRay(collisionPos, -transform.up, Color.green);
if (hitDown.collider != null && hitSide.collider == null)
{
......@@ -44,4 +42,14 @@ public class BaseEnemy : MonoBehaviour {
}
return false;
}
protected bool CheckCollisionCharge(Vector2 dir, Vector3 collisionPos)
{
RaycastHit2D hitSide = Physics2D.Raycast(collisionPos, dir, .1f);
if (hitSide.collider == null)
{
return true;
}
return false;
}
}
......@@ -8,6 +8,7 @@ public class EnemyCharge : BaseEnemy
public float ChargeSpeed;
public bool Charging = false;
public LayerMask lm;
public bool FallOffLedge = false;
void FixedUpdate()
{
......@@ -31,11 +32,17 @@ public class EnemyCharge : BaseEnemy
}
if (Charging)
{ //Will move forward quickly when Charging is True
if (!CheckCollision (fwd, sr.flipX ? leftCollisionPos.position : rightCollisionPos.position))
{
Charging = false;
return;
{ //Will stop or keep going based on FallOffLedge bool
if (!FallOffLedge) {
if (!CheckCollision (fwd, sr.flipX ? leftCollisionPos.position : rightCollisionPos.position)) {
Charging = false;
return;
}
} else {
if (!CheckCollisionCharge (fwd, sr.flipX ? leftCollisionPos.position : rightCollisionPos.position)) {
Charging = false;
return;
}
}
Move (fwd);
speed = ChargeSpeed;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment