Reputation: 31
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);
}
}`
to note, everything has a capsule or box collider.
Upvotes: 1
Views: 363
Reputation: 1
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);
}
}
Upvotes: 0