Heres a basic enemy script I created for the enemies to start with; once you come within their collider they start to come at you unit they touch or unit you escape their box collider or other shape maybe in the future. Again, we want to start simple master the move onto other things.
var enemy : GameObject;
var player : GameObject;
static var attacking = false;
function Update () {
if (attacking){
transform.LookAt(player.transform);
enemy.rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
}
}
function OnCollisionEnter (collisionInfo : Collision) {
if (collisionInfo.gameObject.tag == "player") {
attacking=false;
}
}
function OnCollisionExit (collisionInfo : Collision) {
if (collisionInfo.gameObject.tag == "player") {
attacking=true;
}
}
No comments:
Post a Comment