Initial commit
This commit is contained in:
25
Assets/Scripts/Enemies/Drone.cs
Normal file
25
Assets/Scripts/Enemies/Drone.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using StarterAssets;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class Drone : MonoBehaviour
|
||||
{
|
||||
FirstPersonController player;
|
||||
NavMeshAgent agent;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Awake()
|
||||
{
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
player = FindFirstObjectByType<FirstPersonController>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
agent.SetDestination(player.transform.position);
|
||||
transform.LookAt(player.transform);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Enemies/Drone.cs.meta
Normal file
2
Assets/Scripts/Enemies/Drone.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd94886ba21b8d54babb3b6e94f7859c
|
||||
30
Assets/Scripts/Enemies/EnemyHealth.cs
Normal file
30
Assets/Scripts/Enemies/EnemyHealth.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyHealth : MonoBehaviour
|
||||
{
|
||||
[SerializeField] int maxHealth = 100;
|
||||
int currentHealth;
|
||||
void Awake()
|
||||
{
|
||||
currentHealth = maxHealth;
|
||||
}
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
currentHealth -= damage;
|
||||
if (currentHealth <= 0)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Enemies/EnemyHealth.cs.meta
Normal file
2
Assets/Scripts/Enemies/EnemyHealth.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7607d877a899edd469640c39419addcd
|
||||
27
Assets/Scripts/Enemies/Robot.cs
Normal file
27
Assets/Scripts/Enemies/Robot.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using StarterAssets;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class Robot : MonoBehaviour
|
||||
{
|
||||
[SerializeField] AnimationClip idle;
|
||||
FirstPersonController player;
|
||||
NavMeshAgent agent;
|
||||
Animator animator;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Awake()
|
||||
{
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
player = FindFirstObjectByType<FirstPersonController>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
agent.SetDestination(player.transform.position);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Enemies/Robot.cs.meta
Normal file
2
Assets/Scripts/Enemies/Robot.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e458434f24592374a81c633d2c9a29e8
|
||||
Reference in New Issue
Block a user