Question by 
               Lucky4LuukWolfpackYT · Jan 03, 2016 at 02:29 PM · 
                scripting problemtriggeraicollision detectionboolean  
              
 
              My AI Script doesn't make my AI turn.
Hey guys,
Today I tried to make my own AI script. What is does, is it turns the slimecube when it hits the wall, so it won't get stuck. Here is the script: using UnityEngine; using System.Collections;
 public class PassiveSlimes : MonoBehaviour {
 
     public bool isJumping;
     public bool isColliding;
     public int jumpTimer;
     public int jumpIncrease;
     public int rotateTimer;
     public float jumpForce;
     public float yRotation;
     public int materialSpawnTimer;
     public GameObject MaterialToSpawn;
     public Rigidbody rb;
 
     // Use this for initialization
     void Start () {
         rb = GetComponent<Rigidbody>();
         jumpIncrease = Random.Range(1,5);
     }
     
     // Update is called once per frame
     void Update () {
         if (isColliding == false) {
             transform.position += transform.right * 1 * Time.deltaTime;
         }
         if (jumpTimer == 600) {
             rb.AddForce(transform.up * jumpForce);
             jumpIncrease = Random.Range(1,5);
             jumpTimer = 0;
         }
         jumpTimer += jumpIncrease;
         materialSpawnTimer += 1;
         if (materialSpawnTimer == 500) {
             Instantiate(MaterialToSpawn,this.transform.position,this.transform.rotation);
             materialSpawnTimer = 0;
         }
         transform.rotation = new Quaternion(transform.rotation.x,yRotation,transform.rotation.z,transform.rotation.w);
     }
 
     void OnTriggerEnter (Collider col) {
         if (col.gameObject.tag == "Wall") {
             yRotation = Random.Range (20,180);
             isColliding = true;
             GetComponent<Rigidbody>().transform.eulerAngles = new Vector3 (GetComponent<Rigidbody>().transform.eulerAngles.x, yRotation, GetComponent<Rigidbody>().transform.eulerAngles.z);
             //yRotation += 90;
             transform.position += transform.right * -1 * Time.deltaTime;
             //transform.rotation = Quaternion.Lerp(transform.rotation, new Quaternion(transform.rotation.x,yRotation,transform.rotation.z,transform.rotation.w),Time.deltaTime * 120);
         }
     }
 
     void OnTriggerStay (Collider col) {
         if (col.gameObject.tag == "Wall") {
             isColliding = true;
             //yRotation += 10;
             transform.position += transform.right * -1 * Time.deltaTime;
             //transform.rotation = Quaternion.Lerp(transform.rotation, new Quaternion(transform.rotation.x,yRotation,transform.rotation.z,transform.rotation.w),Time.deltaTime * 120);
         }
     }
 
     void OnTriggerExit (Collider col) {
         if (col.gameObject.tag == "Wall") {
             isColliding = false;
         }
     }
 }
If my AI hits a wall, the problem is, it won't activate the IsColliding boolean, it doesn't turn my guy at all and the yRotation won't change too. At the moment, I know it uses OnTriggerEnter etc, but I tried using OnCollisionEnter(Collision col) too, but that didn't work either. Does anyone know what I should do?
--Lucky
               Comment
              
 
               
              Answer by Lucky4LuukWolfpackYT · Jan 03, 2016 at 04:53 PM
I finally found out what was wrong. I forgot to add a kinematic rigidbody to the walls...
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                