Commit 3bec3cec authored by Benjamin Lane's avatar Benjamin Lane

Created Charging Enemy Script and ChargeEnemey Prefab

parent 75b57033
fileFormatVersion: 2
guid: 22d3bdccbdefc68469c9bd4ac78e2aab
timeCreated: 1490919620
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -11,9 +11,13 @@ public class EnemyCharge : BaseEnemy
void FixedUpdate()
{
// Raycast to check if player is in front with layermask to prevent it from detecting itself
Vector2 fwd = transform.TransformDirection (Vector2.right);
Vector2 fwd;
if (!sr.flipX) {
// Raycast to check if player is in front with layermask to prevent it from detecting itself
fwd = transform.TransformDirection (Vector2.right);
} else {
fwd = transform.TransformDirection (Vector2.left);
}
RaycastHit2D hit;
Debug.DrawRay (transform.position, fwd);
hit = Physics2D.Raycast (transform.position, fwd, DetectionDistance, lm);
......@@ -28,12 +32,12 @@ public class EnemyCharge : BaseEnemy
if (Charging)
{ //Will move forward quickly when Charging is True
if (!CheckCollision (fwd, sr.flipX))
if (!CheckCollision (fwd, sr.flipX ? leftCollisionPos.position : rightCollisionPos.position))
{
Charging = false;
return;
}
Move (fwd, false);
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