Jump to content

Character was on “Sea Level” water. How to remove collider?


StroutFrout
Go to solution Solved by StroutFrout,

Recommended Posts

Hi There. As mentioned in the title, I created a world with the sea level at a certain point, but when the character lands on the water, they just walk on it like any other terrain/surface (as opposed to going underwater). I can’t find a collider on the water objects. What can I do to resolve this? Thanks in advance!

Link to comment
Share on other sites

I should amend my previous statement. There is a collider on the "Underwater Post Processing" game object and if I disable it, my player does fall through the top of the water and ends up in the water. However, the Box Collider attached to the "Underwater Post Processing" object is marked as "Is Trigger" which I would expect to not actually collide with the character?

Link to comment
Share on other sites

A trigger shouldnt make the character collide with it. 
It should go through it. 
Maybe check the player and see if there is any layers that its looking for. 

Link to comment
Share on other sites

Hi Bryan. Thank you for the quick reply.

Looking into it, my Character Controller determines the “Default” layer to be ground/a collision layer, which seems correct to me since the “Default” layer is the layer the Gaia terrain is using as well. However, the “Underwater Post Processing” object is _also_ using the “Default” layer which seems odd to me. So I changed the “Underwater Post Processing” object‘s layer to “Water” which then allows my character to not collide with it, but it also disables Gaia’s Post Processing camera effects, so changing that layer on the water seems like maybe the incorrect thing to do?

Is this a bug or am I missing some key detail here? I imagine any water related colliders _would_ be on the “Water” layer? If it’s layer should remain as “Default”, could you help me understand why the Gaia terrain is using the same layer?

Thanks in advance!

Link to comment
Share on other sites

When the camera hits the trigger thats when the water should update the view with the effects. 
However, there should be exclusions on the actual character itself or change the character layer not the camera layer. 

 

Link to comment
Share on other sites

Agreed. I'm not touching my Main Camera's layer, only the player's collision detection and the layer of the “Underwater Post Processing” object. However I'm still not sure how to solve this. Here are the details and what I have tried:

Scenario 1:

  • Layers:
    • Main Camera: Default
    • Player: player
    • Underwater Post Processing : Default
  • Result: Player walks on water, however if the player enters the water (by toggling the collider off/on), post processing effects will work as expected

Scenario 2:

  • Layers:
    • Main Camera: Default
    • Player: player
    • Underwater Post Processing : Water
  • Result: Player drops into the water, as expected, but no post processing effects occur.

I'm not modifying the camera at all. I'm only changing the “Underwater Post Processing” object‘s layer to “Water”.

Can you please help me understand:

  • What layer should the “Underwater Post Processing” object be set to? It seems like it should be "Water"?
  • Why does the “Underwater Post Processing” object only apply effects when the layer is "Default"?

Thanks in advance!

 

Link to comment
Share on other sites

How do I make the “Underwater Post Processing” object apply effects when the layer is set to "Water"?

Link to comment
Share on other sites

Hi @StroutFrout, please excuse the delayed response.  The physics engine in Unity can be controlled by layer - it is possible to e.g. ignore collisions between layer A and B by switching them off under 
Project Settings > Physics:

image.png

But it is also possible to further fine tune this individually in the code of a script as well. This is most likely what causes the differences between the two scenarios. I could imagine that the "Player" layer has collisions switched off with the "TransparentFX" layer which is the one the trigger colliders are sitting on. 

Please note though that you are developing a workaround for something that should be fixed in a different place: The colliders on the post-processing objects are trigger colliders - which means they are only used to "detect" something,  (like the camera going under water in this case) but should not cause an actual collision. If your player controller is colliding with these objects and the player is walking on water as a result, the player controller is behaving in a non-standard way and might cause you issues in other places where a trigger collider is used as well. If e.g. elsewhere another trigger collider is being used to detect if the player is close to an enemy spawn point, the player controller would "walk" on this trigger as well.

I assume the player controller in your project is using a raycast system to figure out where the ground is and how far it is away from the player model. This raycast then probably also picks up trigger colliders and treats them as a walkable surface. This would need to be fixed by ignoring the trigger colliders in the raycast.
 

Link to comment
Share on other sites

  • Solution

Thank you for the detailed reply! It turns out, the solution that seems to work best for me is to disabled Raycasts colliding with triggers, since Water and Terrain are both on the "Default" layer, the only difference is that the Water game object's collider is labeled as a trigger. So I went into Project Settings > Physics > Toggled "Queries Hit Triggers" to Off. This solved my issue. Thank you again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...