My game is FPS style game and I don't want to use collision for the bullet detection of enemy so I want to know a substitute of this script but without using a collision system:
function OnCollisionEnter(other : Collision){
if(other.transform.tag == "enemy"){
//Do something
}
}
Note: Maybe there are many ways to do it, I actually know some ways to do it, but the important thing here is find the object where it pass(e.g. other.transform.tag == "enemy" that means it do something only if the object tag is equal to enemy)
Know I try it with Raycast, not error but when I quit the collider it doesn't work, it seams Raycast only works for using collider. This is the script I use:
//this script is in the bullet
var moredamage = 1.0;
function Update(){
var hit : RaycastHit;
if(Physics.Raycast(transform.position,transform.forward,hit)){
if(hit.transform.tag == "enemy"){
Debug.Log("You shoot me");
hit.transform.SendMessage("CanDie",moredamage,SendMessageOptions.DontRequireReceiver);
}
}
}
any suggestion, comment or answer would be great.