Character able to easily push rigidbody objects depending on layer

Cheo

Active member
Hello, after some experimenting I realized that UCC characters were able to easily push around rigidbody objects that were on a layer part of the character's Solid Object Layers, at the exception of the Default and Boardable layers. Here is a video showing that :


In this video the green cubes each have a mass of 1, but it is worth mentioning that very heavy objects can be pushed easily depending on the layer, here are heavy objects on the RCC layer being effortlessly moved around (which as you can imagine is quite annoying when using RCC and UCC in the same project) :


Are those behaviors to be expected for a reason, or could this be a bug ? Hope you can help with this, thanks.
 
The character will be able to push any object that it can collide with, and then it's up to the rigidbody's mass to determine how much it can be pushed. The method CharacterLocomotion.PushRigidbody is responsible for the pushing, and the amount that it is pushed depends on the mass of both objects:

Code:
targetRigidbody.AddForceAtPosition((m_Rigidbody.mass / targetRigidbody.mass) * movementMagnitude * -normal, point);
 
Sorry but you're completely missing the key point here, which is how easy the pushing can become depending on the character's layer. Is is it normal that an object that is difficult to push around when on the Default layer becomes much easier to push when its layer is switched to Character for example, without the rigidbody's mass being changed at any moment ?
 
The push force from the character controller is the same regardless of the layer. So it's then up to the rigidbody settings. The mass has some factor in it, and I believe you can change the influence of the layers within the physics settings of Unity but I haven't messed with that in awhile.
 
I believe you can change the influence of the layers within the physics settings of Unity but I haven't messed with that in awhile.
I know about the Layer Collision Matrix in the Physics settings which can prevent or enable collisions between objects of specific layers, but I don't know about other Unity physics settings related to layers, if there are then you'll have to point me in their direction please.

In any case, here's a new video which I hope will be useful :


To summarize :
-When setting the character's colliders' layers to Default in prefab mode, even after changing them to Character in game, rigidbodies on the RCC or Character layers for example can no longer be pushed around easily.
-When reverting that first change and commenting out the line you mentioned in CharacterLocomotion.PushRigidbody, it is still possible to push rigidbody objects easily depending on the layer.

These two experiments suggests that UCC pushes object on specific layers elsewhere in the code. Hope you can take a proper look at this, thanks.
 
Allow me to bump this thread with one interesting detail - when commenting out the PushRigidbody line in CharacterLocomotion.DetectCollisions, the issue still occurs, so whatever piece of code is responsible for making UCC characters easily push objects on specific layers has to be somewhere else.
 
That does give some indication - it's Unity's physics system that is handing the collision in that situation. There aren't any other locations that the character controller adds a force to the rigidbody. I'm still not sure why setting the layer matters unless there is some type physics setting that is different for that layer.
 
Just made a new discovery - the issue seems related to the character's ragdoll, or more specifically its collider objects on the SubCharacter layer. A character who doesn't have a ragdoll while not be able to push rigidbody objects like that, and if he has a ragdoll then the issue can be prevented by unticking the checkbox linking the SubCharacter layer to the on attached to the rigidbody object in the Layer Collision Matrix. In my initial post I mentioned that the issue wasn't happening with USC's boardable layer, and that makes perfect sense as it has that checkbox unticked with Character and SubCharacter. However what I still don't understand is how is it that the issue isn't happening with the Default layer specifically, even though collision between it and SubCharacter isn't disabled by default ?

Anyway, hope that all of this helps, I don't think the default UCC layer settings should be changed as this issue would rather occur with layers added by users themselves or assets that they add, but mention of this should definitely be made somewhere as to spare other users a headache.
 
After taking another look at USC's documentation, I realized that @FastSkillTeam had it right already as he indicates in the Layer Setup page that all RCC layers should ignore collision with the Character, SubCharacter, Visual Effect, Overlay and UI layers. I feel a bit dumb for not reading that earlier, and it does prevent RCC vehicles in the USC demo from being pushed around btw ! Anyway I just hope that UCC's doc can have a paragraph about that if it doesn't already, thanks.
 
Back
Top