Commit a1ce6767 authored by Benjamin Lane's avatar Benjamin Lane

Added Charge Enemy Script

parent c3d5d8ba
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DashEnemy : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
fileFormatVersion: 2
guid: ec9d944083c058349b98a056a253a787
timeCreated: 1488500641
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyCharge : BaseEnemy
{
public float DetectionDistance;
public bool Charging = false;
public LayerMask lm;
void FixedUpdate()
{
// Raycast to check if player is in front with layermask to prevent it from detecting itself
Vector2 fwd = transform.TransformDirection (Vector2.right);
RaycastHit2D hit;
Debug.DrawRay (transform.position, fwd);
hit = Physics2D.Raycast (transform.position, fwd, DetectionDistance, lm);
if (hit)
{
if (hit.collider.gameObject.CompareTag ("Player"))
{//If it sees an object with tag "Player", Charging will be true
Charging = true;
}
}
if (Charging)
{ //Will move forward quickly when Charging is True
if (!CheckCollision (fwd, sr.flipX))
{
Charging = false;
return;
}
Move (fwd, false);
speed = 5;
}
}
}
fileFormatVersion: 2
guid: 43e4e60b0ca845f46b29944b857dc156
timeCreated: 1487898296
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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