-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAIEnemyControl.cs
More file actions
34 lines (28 loc) · 834 Bytes
/
AIEnemyControl.cs
File metadata and controls
34 lines (28 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AIEnemyControl : MonoBehaviour {
public GameObject player;
public GunShootingScript AIgun;
public CharacterController AIcontrol;
public float losLength;
void Start() {
}
void Update() {
int layerMask = 1 << 6;
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity, layerMask)) {
if(hit.collider.gameObject == player) {
transform.LookAt(player.transform);
if(hit.distance < losLength / 100 * 15) {
//Move Away
//AIcontrol.Move(-transform.forward * Time.deltaTime);
} else if(hit.distance < losLength / 2) {
AIgun.shootGun();
} else if(hit.distance < losLength) {
//AIcontrol.Move(transform.forward * Time.deltaTime);
};
}
}
}
}