I decided to use a CharacterController rather than doing rigidbody character control. However, it still made sense to me to have other rigidbody objects in the game. Why not? If I want my character to interact with a rigidbody, I can just manually apply forces via script, and I don’t require nor desire my character to be affected by rigidbody collisions.
The problem I’ve discovered, however, is the character can get stuck to rigidbody objects. I’ve googled this, and there are a lot of threads about rigidbody objects sticking to things, but most are in the context of people who have rigidbody characters, so the issue is not entirely the same. A lot of those threads are about not sliding or something; when I stay I get stuck, I mean permanently stuck, you can’t back out of the collision, the character control is dead.
One thing I tried was to add a PhysicsMaterial with 0 static and dynamic friction to the CharacterController collider, which the CharacterController provides access to. This, however, did not fix the problem.
I then tried setting the rigidbody object collision detection to Continuous, but this also did not fix the problem.
I would guess that the character is actually penetrating the rigidbody collider slightly, and that is why it gets stuck. I’ve never gotten stuck on any other colliders, so it seems to be a rigidbody thing.
Is it wrong to try to have rigidbody objects in a game that uses a CharacterController? I wouldn’t think so. I’m wondering if I need to do something strange like have a second collider around the first collider that is only there for rigidbody collisions. I’m toying with maybe seeing if I can use a layermask so that the character passes right through rigidbody objects and then add an extra trigger collider to detect the collision if I want to provide some reaction. But maybe that’s not solving the problem correctly.
Not sure what approach I should take right now to try to fix it. Curious if anyone else has had to tackle this and what approach was taken.
I don’t have a separate rigidbody or collider on my character object. I did briefly try adding a rigidbody set to isKinematic, but that wasn’t helpful and is probably invalid, so I took it back off. I do have a physics material on my test rigidbody, but I have not set the friction to zero, because if I’m not mistaken, it still needs it’s own friction to respond correctly to the environment and other rigidbody objects.
Perhaps more distressing is when encountering the rigidbody, I start getting errors thrown. Especially after I tried giving the rigidbody a separate layer to that I could have the character controller ignore that layer (testing out the idea of just making character pass through rigidbody objects and trying to use a trigger to handle interactions, though I can’t seem to get the trigger to work).
The error that gets thrown is:
Instancing: Property ‘unity_RenderingLayer’ shares the same constant buffer offset with ‘unity_LODFade’. Ignoring.
UnityEngine.GUIUtility.ProcessEvent (int,intptr,bool&)
That gets thrown hundreds of times per second. Doesn’t seem to crash anything, but it massively pollutes the log.
I don’t think the error was due to the rigidbody even though I only starting seeing it today. I removed the game object entirely and I’m still getting that error. I think it’s an unrelated problem.
I think my trigger collider idea will work if I can get the trigger collider working, but I think it’s getting ignored just like the rest of the object.
Thanks for your help. I figured out the problem, but it wasn’t what I thought. I had implemented some code to keep the character from being able to climb walls, and instead slide down when on a steep slope. It works pretty reliably on terrain, but not so much on other bodies, and it was causing the character to get stuck in a constant slide mode on a sphere rigidbody. So it had nothing to do with the rigidbody.
I’ve solved this for now by making the slide code only react if the layer indicates the collision is with terrain, since that was it’s primary purpose. Presumably, that code should be able to handle other objects too, but it will need some revision for that apparently; that particular code is hard to get right.
I’m not sure about that other error. It’s stopped for now, but if it happens again, I’ll do more research and testing on it. But it wasn’t related so not relevant for this thread.
Given what the real problem was, the title of this thread is misleading. I wonder if I should try to edit the title.