Made enemies shoot
This commit is contained in:
@@ -11,10 +11,14 @@ namespace InterfaceOff.WorldScene
|
||||
[SerializeField] private Rigidbody Body;
|
||||
[SerializeField] private GameObject RendererObject;
|
||||
[SerializeField] private GameObject ExplosionPrefab;
|
||||
[SerializeField] private LineRenderer BulletTracer;
|
||||
[SerializeField] private GameObject GunStart;
|
||||
[SerializeField] private GameObject Head;
|
||||
|
||||
private Quaternion StartRotation;
|
||||
private Vector3 StartPosition;
|
||||
|
||||
private bool StartedShooting;
|
||||
private bool WasAliveLastFrame;
|
||||
private bool Alive = true;
|
||||
|
||||
@@ -31,6 +35,13 @@ namespace InterfaceOff.WorldScene
|
||||
/* Updates the death state */
|
||||
WasAliveLastFrame = Alive;
|
||||
Alive = DeathIndex >= Player.FrameIndex;
|
||||
|
||||
/* Checks if it is about to die or kill */
|
||||
if (DeathIndex == (Player.FrameIndex + 10) && !StartedShooting)
|
||||
{
|
||||
StartCoroutine(routine: ShootyShooty());
|
||||
StartedShooting = true;
|
||||
}
|
||||
|
||||
/* Checks if it just died */
|
||||
if (!Alive && WasAliveLastFrame)
|
||||
@@ -50,6 +61,28 @@ namespace InterfaceOff.WorldScene
|
||||
RendererObject.SetActive(true);
|
||||
Body.Sleep();
|
||||
}
|
||||
|
||||
/* Check for resurrection */
|
||||
if (Alive && !WasAliveLastFrame)
|
||||
{
|
||||
StartedShooting = false;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ShootyShooty()
|
||||
{
|
||||
BulletTracer.enabled = true;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
BulletTracer.SetPosition(0, Head.transform.position);
|
||||
BulletTracer.SetPosition(1, Player.transform.position);
|
||||
BulletTracer.SetPosition(2, GunStart.transform.position);
|
||||
|
||||
yield return new WaitForFixedUpdate();
|
||||
}
|
||||
|
||||
BulletTracer.enabled = false;
|
||||
}
|
||||
|
||||
private IEnumerator Suicide()
|
||||
|
||||
Reference in New Issue
Block a user