Surface manager for water plane

Surface Manger works great detecting the different textures and the Surface Identifier. Congrats for the nice work. But would be possible for water surface to detect when the water is made of a water plane, instead of the texture? Usually all of the water renders are just a water plane that you add to the scene.
I have tried to add the Surface Identifier to one of them and it doesn't work.
Any plan or workaround to use the water planes as reference to the Surface Manager?
Thanks
 
As long as your water plane has a collider on it then Surface Identifier should work. If you are using a different layer for the water plane then double check that the cast is hitting that layer (such as the hitscan layers for a shootable weapon).
 
The Surface Manager does not recognize triggers. You could make your water plane a regular collider and then change the collision layers so the character can walk through it.
 
You could make your water plane a regular collider and then change the collision layers so the character can walk through it.
Only this will not work. To fix this problem:

1. As Justin said, make your water plane a regular collider and then change the collision layer to Water, then in Project Settings > Physics, change the collide setting so the character can walk through water.

2. Open CharacterFootEffects.cs, change line 376, in FootStep function:
C#:
            if (Physics.Raycast(foot.position + m_CharacterLocomotion.Up * 0.1f, -m_CharacterLocomotion.Up, out hit, 0.11f + m_FootOffset, m_LayerManager.IgnoreInvisibleCharacterWaterLayers, QueryTriggerInteraction.Ignore)) {
to:
C#:
            if (Physics.Raycast(foot.position + m_CharacterLocomotion.Up * 0.1f, -m_CharacterLocomotion.Up, out hit, 0.11f + m_FootOffset, m_LayerManager.IgnoreInvisibleCharacterLayers, QueryTriggerInteraction.Ignore)) {

3. Open Fall.cs, change line 101, in OnGrounded function:
C#:
                    SurfaceManager.SpawnEffect(m_CharacterLocomotion.GroundRaycastHit, m_LandSurfaceImpact, m_CharacterLocomotion.GravityDirection, m_CharacterLocomotion.TimeScale, m_GameObject, m_Transform.forward, false);
to:
C#:
                    RaycastHit hit;
                    if (Physics.Raycast(m_CharacterLocomotion.transform.position + m_CharacterLocomotion.Up * 0.1f, -m_CharacterLocomotion.Up, out hit, 0.3f, m_LayerManager.IgnoreInvisibleCharacterLayers, QueryTriggerInteraction.Ignore))
                    {
                        SurfaceManager.SpawnEffect(hit, m_LandSurfaceImpact, m_CharacterLocomotion.GravityDirection, m_CharacterLocomotion.TimeScale, m_GameObject, m_Transform.forward, false);
                    }
 
Last edited:
hello,

I kind of have this working but I think the issue is that the surface manager is still triggering the terrain texture. Any idea of how I would disable the terrain texture if the player has entered the water zone collider?

Thanks,
Nathan
 
Hello, i'm having the exact same issue, while having a collider on my plane, when i try to modify the scripts as @TrungDong suggested, i have an error :

"Opsive\UltimateCharacterController\Scripts\Character\CharacterFootEffects.cs(396,140): error CS0103: The name 'm_LayerManager' does not exist in the current context"

For both scripts.

I also tried, in my Character Layer Manager component, to check Water in the Invisible Layers, then choose the Water layer in my water plane, it still didn't work, the character goes through the water but it's the ground foosteps (inside the water) that triggers footstep sounds.
Tried to check Water in the Solid Objects Layers in the Character Layer Manager, and on the project settings uncheck Character for the Water layer, still didn't work.
 
@RaeJjino

I gave up on this because I have so many other pressing issues to deal with first. However, it is probably the most annoying thing personally I haven't been able to fix.

If anyone has this working would you mind explaining how you did so?

Thanks in advance,
Nathan
 
The name 'm_LayerManager' does not exist in the current context"
Of course, it does not exist. "m_LayerManager" is the name of the variable in old versions. In new versions, it has been renamed to "m_CharacterLayerManager".
Remember to modify the m_CharacterLocomotion.Up * 0.1f and the max distance of the raycast. It depends on your depth of water.
In my project, it is m_CharacterLocomotion.Up * 0.8f and 1.1f + m_FootOffset

C#:
if (Physics.Raycast(foot.position + m_CharacterLocomotion.Up * 0.8f, -m_CharacterLocomotion.Up, out hit, 1.1f + m_FootOffset, m_CharacterLayerManager.IgnoreInvisibleCharacterLayers, QueryTriggerInteraction.Ignore)
 
If anyone has this working would you mind explaining how you did so?

There was a bug in the logic. The system cast a ray from the position 0.1 meters above the foot downward, with the ray length is 0.11 meters. If the ray collide with the water, the sound and effect is played.

But the first problem is, the ray ignored the water layer, it will never collide with the water!!! (m_CharacterLayerManager.IgnoreInvisibleCharacterWaterLayers)
So we need to fix it by changing m_CharacterLayerManager.IgnoreInvisibleCharacterWaterLayers to m_CharacterLayerManager.IgnoreInvisibleCharacterLayers

The second problem is, what if the water plane is 0.2 meters above the foot? Of course, the ray will never hit. Because It's starting point is 0.1 meters above the foot. So we need to modify the m_CharacterLocomotion.Up * 0.1f to the height which fit with our water height. In my case it is 0.8f. And remember the ray length, instead of 0.11f, let's change to 0.8f or even 1f or 1.1f for sure.
 
It works !!!!!

You are amazing kind sir, i managed to make it work thanks to your last message, i understood that i had to uncheck Water from the character layer manager, thank you so much ! ? ?
Uhm, since you seem to be a master of Opsive's systems, if you could take a look at my new topic... Wow who just said that ><
 
Top