- Home /
Question by
Le_Tai · Dec 06, 2014 at 06:57 PM ·
collisionprojectile
Filter Collision by tag not working
Im working on a fps project and I want the projectile react different on each type of object, here my code:
void OnCollisionEnter (Collision other) {
if(other.gameObject.tag!="Player"||other.gameObject.tag!="impenetrable")
{
if(Physics.Raycast (transform.position,transform.TransformDirection(Vector3.forward),out hit))
{
follow=new GameObject();
follow.transform.position=hit.transform.position;
follow.transform.rotation=transform.rotation;
follow.transform.parent=hit.transform;
print (hit.transform);
}
collider.isTrigger = true;
transform.Translate (new Vector3(0//rigidbody.velocity.x*hardness
,0//rigidbody.velocity.y*hardness
,rigidbody.velocity.z*-hardness));
rigidbody.isKinematic = true;
hashit = true;
}
but it do anything on object tagged with "Player" and "impenetrable". I had done similar thing without a problem in some of my previous project so is this a bug or I did some thing wrong?
thanks!
Comment