#blender imported mesh collider, inverted normals
1 messages · Page 1 of 1 (latest)
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);
}
}
}
What object has this script on it
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
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
Yeah, I'm not falling through, but the normal seems... inverted??
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
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
Just tried importing as a different filetype (.obj) and nothing
Yeah I don't get it, you fall through mesh colliders if they are inverted
is your mesh actually double sided?
No, I can see through it when I import the faces in unity or clip through
can you link the mesh?
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
Only in edit mode, and not since I've been recalculating the normals and stuff
Why does the land have a rigidbody as a parent?
Because it's a body orbiting in space, it will change in the main game, but for the demo, it'll do
I can't get it to have inverted normals 🤷 it works correctly here, what version of Unity are you using?
2019.4 LTS
The same mesh works for you??
That's wild
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.
There's a bug in compute shaders in the latest LTS lol, I just switched
Ugh
I can't find anything relevant online, it's hard to sift through it all
Finding nothing
Hey, I still haven't solved this
Currently using the latest and the normals are still reversed
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)
Should I submit a bug report? What gives?