hey, i have a problem with my colliders attached to my enemies!! this is the code i use for the enemy, and they all have a box collider on it:
var target : Transform;
var huntRange : float = 10.0;
var rotationSpeed : float = 0.1;
var moveSpeed : float = 3.0;
var runSpeed : float = 5.0;
private var speed : float;
function Start() {
target = GameObject.FindWithTag("Player").transform;
}
function Update() {
var hit : RaycastHit;
var direction : Vector3 = target.position - transform.position;
if(Player_Simply.running || direction.magnitude < huntRange
|| (Physics.Raycast(transform.position , direction, hit)
&& hit.collider.gameObject == target.gameObject)) {
//Shorter than writing 2-3 ifs that do the same thing
if(Player_Simply.running) speed = runSpeed;
else speed = moveSpeed;
transform.rotation = Quaternion.Slerp(transform.rotation,
Quaternion.LookRotation(direction),
rotationSpeed);
transform.position += transform.forward * speed * Time.deltaTime;
}
}