Skip to content
Snippets Groups Projects
Commit 4b7a0bb9 authored by Graham Solie's avatar Graham Solie
Browse files

Tweaks to AI

parent 884aa8d7
No related branches found
No related tags found
No related merge requests found
Showing
with 22 additions and 37 deletions
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -7,9 +7,9 @@ public class EnemyAI : MonoBehaviour {
public Transform target;
private Rigidbody2D Enemy;
private Animator myAnimator;
private bool LookRight = true;
private bool LookRight = false;
public bool set;
private float speed = 3;
private float speed = 1;
void Start() {
......@@ -27,13 +27,12 @@ public class EnemyAI : MonoBehaviour {
public bool inAttackRange() {
if (Vector3.Distance(transform.position, target.position) < 2f) {
// Debug.Log("In Zone");
if (Vector3.Distance(transform.position, target.position) < 1f) {
Debug.Log("In Zone");
return true;
}
else {
// Debug.Log("In Zone- not");
return false;
}
......@@ -43,6 +42,7 @@ public class EnemyAI : MonoBehaviour {
public bool moveToEnemy() {
// Debug.Log("range");
if (Vector3.Distance(transform.position, target.position) > 2) {
myAnimator.SetBool("speed", true);
return true;
}
else {
......@@ -70,9 +70,11 @@ public class EnemyAI : MonoBehaviour {
*/
public void attack() {
Debug.Log("attacking");
myAnimator.SetBool("speed", false);
myAnimator.SetBool("attack", true);
}
public void run() {
float option = Random.Range(0, 2);
......@@ -89,23 +91,26 @@ public class EnemyAI : MonoBehaviour {
public void moveToPlayer() {
// Debug.Log("attacking");
//rotate to look at the player
transform.LookAt(target.position);
transform.Translate(new Vector3(speed * Time.deltaTime, 0, 0));
//transform.LookAt(target.position);
myAnimator.SetBool("speed", true);
/*
if (transform.position.x > 0 && !LookRight || transform.position.x < 0 && LookRight) {
LookRight = !LookRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
if (target.transform.position.x <= transform.position.x) //players spot in world space as opposed to enemy "self" spot
{
transform.rotation = new Quaternion(0, 180, 0, 0); // flips enemy around to face the player on x axis only
}
*/
else if (target.transform.position.x >= transform.position.x) //players spot in world space as opposed to enemy "self" spot
{
transform.rotation = new Quaternion(0, 0, 0, 0); // flips enemy around to face the player on x axis only }
}
}
public void BuildDecisionTree() {
//Left SubTree
DecisionTree Run = new DecisionTree();
Run.setAction(run);
......
No preview for this file type
sceneSetups:
- path: Assets/Scenes/mainScene1.unity
- path: Assets/Scenes/arena.unity
isLoaded: 1
isActive: 1
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Base path: C:/Program Files/Unity/Editor/Data
Cmd: getPlatforms
Cmd: compileSnippet
api=4 type=0 insize=560 outsize=1734 kw=SHADOWS_DEPTH pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=1 insize=560 outsize=218 kw=SHADOWS_DEPTH pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=0 insize=6930 outsize=2118 kw=DIRECTIONAL LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=1 insize=6930 outsize=642 kw=DIRECTIONAL LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=0 insize=3762 outsize=1342 kw=DIRECTIONAL pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=1 insize=3762 outsize=570 kw=DIRECTIONAL pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=0 insize=6825 outsize=2118 kw=DIRECTIONAL LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=1 insize=6825 outsize=642 kw=DIRECTIONAL LIGHTMAP_OFF DYNAMICLIGHTMAP_OFF pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=0 insize=3658 outsize=1342 kw=DIRECTIONAL pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
Cmd: compileSnippet
api=4 type=1 insize=3658 outsize=570 kw=DIRECTIONAL pd=UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING ok=1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment