Hello, i have a bit of a problem with that the Enemy moves but not to me, it moves where ever it wants and threw walls with colliders… i just want it to attack me , haha if you have time baby you can help me understand and make a attack for the enemy to
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyLogic : MonoBehaviour {
//EnemyHealth
public int health = 100;
//EnemyHealth
//EnemyMovement
public float speed = 3.0f;
public float obstacleRange = 5.0f;
private bool _alive;
//EnemyMovement
//EnemyMovement
void Start () {
_alive = true;
}
//EnemyMovement
//EnemyHealth
void Update()
{
if (health <= 0)
{
Dead();
}
//EnemyMovement
if (_alive) {
transform.Translate (0, 0, speed * Time.deltaTime);
}
Ray ray = new Ray (transform.position, transform.forward);
RaycastHit hit;
if (Physics.SphereCast (ray, 0.75f, out hit)) {
GameObject hitObject = hit.transform.gameObject;
}
}
public void SetAlive(bool alive) {
_alive = alive;
}
//EnemyMovement
//EnemyHealth
void ApplyDamage(int damage)
{
health -= damage;
}
//EnemyHealth
//EnemyHealth
void Dead()
{
Destroy (gameObject);
}
//EnemyHealth
}