#blender imported mesh collider, inverted normals

1 messages · Page 1 of 1 (latest)

worn stirrup
#
private void OnCollisionStay(Collision collision)
    {
        foreach(ContactPoint cont in collision.contacts)
        {
            float dot_norm = Vector3.Dot(transform.up, cont.normal);
            if( dot_norm > 0.01f)
            {
                Debug.DrawLine(cont.point, cont.point + cont.normal, Color.blue, Time.fixedDeltaTime);
                _playerstate = PlayerState.Grounded;
                normal = cont.normal;
                velocity_frame = cont.otherCollider.gameObject.GetComponentInParent<Rigidbody>().GetPointVelocity(cont.point);
            }
            else
            {
                Debug.DrawLine(cont.point, cont.point + cont.normal, Color.magenta, Time.fixedDeltaTime);

            }
        }
    }
quasi granite
#

What object has this script on it

worn stirrup
#

The player controller

#

Also, there's more info if you jump to the message I started the thread from and scroll

#

Or just look in talk lol

quasi granite
#

I don't know if you can even contact the other side of a mesh collider, if you're not falling through that surface then the normals are correct and what you're seeing is the normal of the contact on the player body

#

but I don't remember it working that way so I might be mistaken there

worn stirrup
#

It doesn't make any sense

#

And the check to determine if it's a valid grounding surface doesn't work and I can't walk while I'm on it.

#

But it works with boxes and spheres

#

Just played around with the import settings, nothing helpful

quasi granite
#

I note that Debug.DrawRay is a thing, and you do not need to provide a time argument unless you want to draw it for more than a single frame.
I'm taking a look at a project with a mesh collider now

worn stirrup
#

Just tried importing as a different filetype (.obj) and nothing

quasi granite
#

Yeah I don't get it, you fall through mesh colliders if they are inverted

#

is your mesh actually double sided?

worn stirrup
quasi granite
#

can you link the mesh?

worn stirrup
quasi granite
#

is as I expect

#

I slightly modified your code but it shouldn't make a difference, you can see it's not inverted

private void OnCollisionStay(Collision collision)
{
    foreach (ContactPoint cont in collision.contacts)
    {
        float dot = Vector3.Dot(Vector3.up, cont.normal);
        DebugUtils.DrawArrow(cont.point, cont.normal * 1.2f, dot > 0.01f ? Color.blue : Color.magenta);
    }
}```
#

You haven't done anything weird with the object scale have you?

#

I can't even get that to cause the issue tbh

worn stirrup
quasi granite
#

Why does the land have a rigidbody as a parent?

worn stirrup
quasi granite
#

I can't get it to have inverted normals 🤷 it works correctly here, what version of Unity are you using?

worn stirrup
#

The same mesh works for you??

#

That's wild

quasi granite
#

I am using 2022 so there might be a difference in the way meshes work under certain conditions. If you're not using the latest LTS I would check the release notes for newer ones to see if there's a fix in there.

worn stirrup
#

Ugh

#

I can't find anything relevant online, it's hard to sift through it all

worn stirrup
#

Finding nothing

worn stirrup
#

Hey, I still haven't solved this

worn stirrup
#

Ugh

#

This is delaying me greatly

#

I don't know how to work around this, I tried to sense whether the object is a mesh collider and it didn't work. I'm just gonna list out what we know about the issue:

  • the mesh is functional, vertx tested it successfully
  • there's a contradiction between (1) having a reversed normal and (2) not falling through
  • problem doesn't apply to shape colliders
  • import settings not helpful
  • import type doesn't matter
  • mesh is not double sided
  • the object scale is not relevant
  • Unity version is irrelevant(so it seems)
worn stirrup
#

Should I submit a bug report? What gives?

quasi granite
#

Simplify your setup, just have a ball with the detection script on it that falls onto a newly placed version of the mesh in an empty scene

#

if it's still not doing what you expect, make a bug report with that setup