the sun is leaking.
This commit is contained in:
parent
43a0b83748
commit
b968ed3060
4 changed files with 212 additions and 70 deletions
|
|
@ -4,7 +4,9 @@ using UnityEngine;
|
|||
public class Enemy : Entity
|
||||
{
|
||||
[Header("Targetting")]
|
||||
public Entity closestTarget;
|
||||
public Entity closestTarget;
|
||||
public float engagementRange;
|
||||
public bool detectedPlayer = false;
|
||||
[Header("Direction")]
|
||||
public float acceleration;
|
||||
public Transform[] possibleDirections;
|
||||
|
|
@ -23,7 +25,11 @@ public class Enemy : Entity
|
|||
|
||||
protected override void FixedUpdate()
|
||||
{
|
||||
if (stalled || !closestTarget)
|
||||
if (!detectedPlayer && Vector3.Distance(transform.position, closestTarget.transform.position) < engagementRange)
|
||||
{
|
||||
detectedPlayer = true;
|
||||
}
|
||||
if (stalled || !closestTarget || !detectedPlayer)
|
||||
{
|
||||
rb.VelocityTowards(Vector2.zero.ScaleToMagnitude(speed), acceleration);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EnemySpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Marisa player;
|
||||
public Enemy[] enemiesToSpawn;
|
||||
public List<Transform> spawnPoints;
|
||||
public float spawnRate;
|
||||
public float currentSpawnTime;
|
||||
|
||||
public void SpawnEnemy()
|
||||
[SerializeField] private float currentSpawnTime;
|
||||
[SerializeField] private Transform enemyFolder;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
currentSpawnTime -= Time.deltaTime;
|
||||
if (currentSpawnTime < 0)
|
||||
{
|
||||
currentSpawnTime = spawnRate;
|
||||
SpawnEnemy(enemiesToSpawn[Random.Range(0, enemiesToSpawn.Length)], spawnPoints[Random.Range(0, spawnPoints.Count)].position);
|
||||
}
|
||||
}
|
||||
|
||||
public void SpawnEnemy(Enemy enemy, Vector3 location)
|
||||
{
|
||||
Enemy newEnemy = Instantiate(enemy, location, Quaternion.identity);
|
||||
newEnemy.transform.SetParent(enemyFolder);
|
||||
newEnemy.closestTarget = player; //idk if there's actually gonna be any other target lol
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue