Hi,I’ve been working on my FPS for a while,everything went fine but I have a problem where the bullet goes through the enemy(AI) without colliding,and yes,the enemy has
1.Box collide
2.Correct tag
3.Not retarded(maybe?)
This is my code:
EnemyAI
var MoveSpeed : float = 5;
var Player : Transform;
var MaxDist = 10;
var MinDist = 2;
private var soldier : GameObject;
var Health : float = 100;
// Use this for initialization
function Start () {
soldier = GameObject.Find("Soldier");
}
// Update is called once per frame
function Update () {
transform.LookAt(Player);
if(Vector3.Distance(transform.position,Player.position) >= MinDist){
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
soldier.animation.CrossFade("RunAim");
}
else
{
soldier.animation.CrossFade("StandingAim");
}
if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
gameObject.GetComponent(AIGun).Fire();
if(Health <= 0.0)
Destroy(gameObject);
}
function AdjustHealth(Adj : float){
Health -= Adj;
}
The RayCastGun(only the part where the collide with enemy is)
if(hit.collider.tag == "Player"){
Instantiate(ConcreteImpact,hit.point,Quaternion.FromToRotation(Vector3.forward,hit.normal));
hit.collider.SendMessageUpwards("AdjustHealth",Damage,SendMessageOptions.DontRequireReceiver);
}
And finally,my game demo
https://dl.dropbox.com/u/87658078/BulletProblem.rar