Character Moving through tree collider

Zaddo

Active member
When I push my character up against tree's it can sometimes slide into the tree. This does not happen with colliders that are not part of the terrain system. The debug raycast in CharacterLocomotion.DetectCollisions shows the tree is detected, but as I move around the tree, the raycasts appear to stop detecting the tree.

Interestingly you will notice that UCC automatically slides the character out of the tree collider after the character is inside.

Notes:
  • this only happens in third person, not first person.
  • The tree collider is a cylinder
  • The collider layer mask does include the tree layer
  • Collision settings:
    1688195885297.png
Here is a short video showing the problem, with physics debugger visible in bottom. I am running UCC 3.0.9 with Unity 2021.3.15f1.

 
Last edited:
I have been debugging this for several hours. It is doing my head in because you have to catch the call to DetectCollisions when it fails. And so I am dumping out heaps of logs to work out what is going on.

The DetectCollisions seems to fail when it does multiple iterations of the do loop. The do loop does a second iteration because I am sliding it along the face of the tree and the conditions in the code snippets below are true.
C#:
if (closestRaycastHit.distance < movementMagnitude && (movementDot = Vector3.Dot(normalizedTargetMovement, projectedNormal)) > -0.99f)
    if (forward.sqrMagnitude > 0)

I am now reasonably sure this is likely a bug in the DetecteCollisions code.

Debug Notes (maybe this will help...)
1. I start by pushing directly into the tree, then tap the "D" key
2. Because we are now moving diagonally, the first frame after tapping "D" moves us closer to the tree
3. The next frame, we get a collision with the tree, the closestRaycastHit.distance is zero. The following code executes, which updates our targetPosition.
C#:
if (!UsingGroundCollisionDetection || !UsingVerticalCollisionDetection || Mathf.Abs(Vector3.Dot(m_Up, m_Rigidbody.InverseTransformDirection(closestRaycastHit.normal))) < 0.9995f)
{
    targetPosition += offset * 0.1f;
    settled = false;
}
4. Step 3 repeats a few times until targetPosition += offset * 0.1f, moves us far enough that we are now through the collider and the character moves into the tree

Take this diagnosis with a grain of salt. It is a really difficult problem to debug because it needs to run over multiple frames.
 
Last edited:
Sorry for spamming forum, I get tunnel vision when working on problems ;-)

I recreated the problem with a pristine install of UCC. I sent an email to support with a link to a zip file. If you unzip this into a UCC project and open the test scene, you can reproduce the problem (go to the locomotion zone). See below video for example

If possible, could you please provide a code fix? I have a lot on my plate ATM and I am reluctant to upgrade UCC/UIS right now.

 
Last edited:
There have been collision improvements in the newer versions so you should update first. The fixes were specifically related to slopes so it may already be fixed :)
 
The testing I did in the pristine environment was using the latest version from the asset store. I was hopeful I had made a mistake and a fresh download would work, so I cleared my asset store cache and downloaded again. But unfortunately, the latest version still has the problem.

The current version from the asset store is 3.0.12. But the asset store description is showing 3.0.13 as the current version? It could be the version number was not updated in the latest package, or there is a problem on the asset store?
 
Last edited:
I just tried and was able to reproduce this. I'll have it fixed in the next update. If it's something small I'll post the fix here.
 
Top