In a probuilder object with inverted normals. Collision seems to not work with this one item

Viewed 45

I have made my level out of a probuilder object that has inverted normals so the player may exist inside of it. This has caused some issues as for some reason. The projectiles that my enemies create ignore the player, only when inside the level. As when I take them out and test them on a flat plane, it works fine.

The code for the Bullet Finding Player Collision :`private void OnCollisionEnter(Collision collider) { playerHitbox target = collider.gameObject.GetComponent();

    if (target != null)
    {
        PlayerManager.instance.takedmg(dmg);
        Destroy(gameObject);
    }
    else
    {
        Destroy(gameObject);
    }
}`

ANd this is the inspector view of the level object

to note, everything has a capsule or box collider.

1 Answers

Have you tried resetting the colliders? That might get them to register better.

Or maybe the code does not allow multiple collisions at once and is therefore needed to be improved so something like this may work

private void OnCollisionEnter(Collision collider) { 
playerHitbox target = collider.gameObject.GetComponent();

    if (distance(transform.position,target.position)
    {
        PlayerManager.instance.takedmg(dmg);
        Destroy(gameObject);
    }
    else
    {
        Destroy(gameObject);
    }
}
Related