- Home /
help with AI avoidance script
if(Vector3.Distance(target.position, myTransform.position) < range && Vector3.Distance(target.position, myTransform.position) > attackRange){
 var hit : RaycastHit;
 if(Physics.Linecast(myTransform.position,target.position,hit)){ 
             if(hit.collider.gameObject.tag == "Player"){
                 myTransform.LookAt(Vector3(target.position.x, myTransform.position.y, target.position.z));
                 myTransform.localEulerAngles = Vector3(0,myTransform.localEulerAngles.y,0);
                 myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
             }
             else{
             myTransform.position += myTransform.right * moveSpeed * Time.deltaTime;
             
         }
         
         
         }
 
 }
the original purpose of the hit check was to stop the enemies from colliding, which it did, only to have 1 enemy stop whenever it was behind the other enemy.. so I thought I would have him run around the side (the else function), you can move around in a way to get them to overlap again which was what i was trying to prevent in the first place.. so question is,, do I need to do a 2nd raycast in the else or is there a better way to do this, Thanks
Your answer
 
 
             Follow this Question
Related Questions
Have falling object exit from a collider after collision? 2 Answers
How can I draw a ray for direction object is moving? 1 Answer
AI Movement Inside Volume 1 Answer
My Raycast acts like it's hitting something when it isn't 0 Answers
How to know how far one object are from the corners of another object. 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                