Question by
UserNameIsAlredyTaken · Nov 24, 2018 at 11:52 PM ·
physicsignorecollision
Can't make bullet ignore colisions
I want to force the bullets to pass through the platforms in case they fall on top of them
So I use this code:
private void OnCollisionEnter(Collision collision)
{
int colliderLayerMask = (int)Mathf.Pow(2, collision.gameObject.layer);//get the LayerMask number of the collider
if(colliderLayerMask == m_Platform)
{
if(collision.collider.bounds.max.y > transform.localPosition.y)
{
Physics.IgnoreCollision(GetComponent<Collider>(), collision.collider, true);
}
}
}
I am sure that the platform side is determined correctly, but Physics.IgnoreCollision() is still not working.
What am I doing wrong?
Comment
Your answer
Follow this Question
Related Questions
Determining if my target is standing upright 4 Answers
RayCasting 0 Answers
Rigidbody projectile misses collider 1 Answer
Projectile Changing Angle BEFORE Impact 0 Answers
simulate a physics material bounce to find where it will land 0 Answers