As you can see in the video, raycasts start and stop working (the terrain raycast is a special raycast from ULTIMATE TERRAINS, no physical raycast) I tried to make a reproduceable example, but I couldn't - if I generate a simple mesh (plane) in another scene, everything works great. But in the ULTIMATE TERRAINS scene, even simple colliders like the cube in the video won't get detected by raycasts. It's not a layer problem, because everything I do is uncheck the enabled toggle on the BoxCollider, re-check it and everything works for like 1 second. Is this a performance problem? Are there too many Mesh Colliders, so the whole Physic-Raycast System breaks?
I would take this up with who ever manages the assets you're using, probably can provide more help then any of us. Might be, that would be my guess but i have no idea how this raycast works.
"this raycast"? In the Video 2 bool variables are shown TerrainHit and GroundHit TerrainHit works, it's the one included in the asset, but it will only test against the terrain surface, so if I have a building on this terrain it will be ignored by the terrain raycast. The GroundHit is the UnityEngine.Physics.Raycast() and this raycast breaks somehow. Current reproduction: I made a new scene with just a plane and my Charakter and everything works fine until I move him below the plane and back up again (dragging him with the translate-gizmo) - then all raycasts are broken. I tried reproducing this in a new empty project, but the error seems to be more complex than just moving an object. But for now I know it has nothing to do with the assets, only with my Code in combination with Unitys Raycast System.
Ok I found the Bug. I think the issue began when I made changes to my prefab inside the scene, clicked on "apply all" and suddlenly random values where resetted. In the simple demo scne with just the plane and the character, I tried diabling all scrips, using some test cubes and so on - till I checked the prefab structure. The Top Prefab was somehow corrupted (it was just an empty gameobject with no components/scripts attached, but still caused strange behaviour on it's children) So I deleted the Prefab, created a new empty game object, and made a new prefab out of it in a new folder. Now the bug is gone. Thread closed.
Edit: After playing for 3 minutes, without a single prefab in my scene, it still stops working. So it does not depend on the scene and not on the code as I understand - because once it stopped working, it won't detect any raycast. I have 3 scripts to test this. My player detecting the ground, my weapon (which is a completely independent script) and one extra test script. And once the raycasts are broken, none of the three detects any other collider anymore. I can spawn new cubes, attach the test raycast script to them and they won't detect each other, nor the ground nor the player collider. No layermasks at all The test script is just: Code (CSharp): using UnityEngine; public class RaycastTest : MonoBehaviour { public bool hitGround; public string hitInfo; // Update is called once per frame void Update() { RaycastHit hit; hitGround = Physics.Raycast(transform.position + Vector3.up*2, Vector3.down, out hit, 3); if (hitGround) { hitInfo = hit.collider.name; } } }
We're having the exact same issue as ure describing. It only happens when upgrading to 2018.3 and we have not been able to reproduce it in an empty project. But it did happen in an empty scene with only 1 plane and a bunch of raycasts, where the raycasts would only hit _half_ of the plane, and the other half of the plane would be missed, and when doing the same test with a grid of planes the raycasts would hit half of each individual plane.
Exactly, I fixed it by starting over. Completely new project, copying the most important parts & scripts, recreating GameObjects. Seems like the only thing one can do.
Same issue, two objects with same layers, but one of them does not get raycast hit properly. I have checked every thing. Seems layer mask does not work