

LookPosition = rectPosition - rectOffset RectPosition = castFrom + castDirection * hit.distance LookRotation, castDistance, obstructionMask, QueryTriggerInteraction.Ignore if (Physics.BoxCast(ĬastFrom, CameraHalfExtends, castDirection, out RaycastHit hit, Second, do the same for the box cast in OrbitCamera.LateUpdate. ProbeDistance, probeMask, QueryTriggerInteraction.Ignore if (!Physics.Raycast(īody.position, -upAxis, out RaycastHit hit,

Add QueryTriggerInteraction.Ignore as a final argument to the ray cast. The first query is in MovingSphere.SnapToGround.
#UNITY 3D STORE CODE#
But we never want to detect triggers with the code what we have right now, so let's make that explicit, regardless of the project setting. Whether triggers are detected can be configured via the Physics / Queries Hit Triggers project setting. Even then, in general the two physics queries that we currently have are meant for regular colliders only, not triggers. Ignoring Trigger CollidersĪll the water volume objects are on the Water layer, which should be excluded from all layer masks of both the moving sphere and the orbit camera. An example of this is the curving water bridge, for which I made a simplified convex collider. A concave mesh automatically generates a convex version that wraps it, but that can lead to places where it pokes out of the desired water volume. Note that mesh colliders that are triggers have to be convex. Those have to be set to triggers as well, which can be done via the Set Trigger option in the ProBuilder window. A few places required more complex ProBuilder meshes to fit the volume.

I've used box colliders without a mesh for most of the volume, scaled slightly larger than needed so there won't be any gaps in the water. The water's volume has to be described with colliders set to be triggers. They're visible from above but not from below. The water surface is made with single-sided flat meshes that have a semitransparent blue material. Our water will also work with arbitrary gravity, but this scene uses simple uniform gravity. It has various shore configurations, two surface levels, two water tunnels, a water bridge, and places where you can walk underneath the water. To demonstrate water I've created a scene that contains a swimming pool. PhysX doesn't support it directly, so we have to create an approximation of water ourselves. However, there is no out-of-the-box solution for interactive water. Lots of games contain water and it's often swimmable. I've upgraded to Unity 2019.4 LTS and ProBuilder version 4.2.3, so some of the visuals have changed.
