Hello all,
I’m a little stuck here. I’m using UnityScript and I have a first person controller and a few enemies with a following script and that script has them taking damage when hit with a bullet from my gun, and all that works fine, what I’m looking to find out is how to stop the enemies from going through all my colliders, the first person controller cant go through them, but all the enemies can, I’m wondering if it’s my script that allows this to happen or if it’s something else, I’ve gone through the script loads but cant find anything amiss. Thanks all.
> #pragma strict
var target : Transform;
var moveSpeed = 3;
var rotationSpeed = 3;
var myTransform : Transform; //current transform data of this enemy
var hitPoints = 10.0;
function Awake(){
myTransform = transform; //cache transform data for easy access/preformance
}
function Start(){
target = GameObject.FindWithTag("Player").transform; //target the player
}
function Update () {
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
//move towards the player
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
function ApplyDamage(damage : float){
if(hitPoints <= 0.0){
return;
}
hitPoints -= damage;
if(hitPoints <= 0.0){
Invoke("DelayedDetonate",0);
}
}
function DelayedDetonate(){
Destroy(gameObject);
}