OnCollisionStay not called on terrain collision IF the center of the object is on the inside of the terrain
I have an object that can properly collide with terrain when above it (it functions as intended), but it stops working once the ORIGIN is inside the terrain. I put a print statement in the collision function for testing, and it turns out that OnCollisionStay is never called AT ALL when the origin is inside the terrain.
Basically, it appears that objects don't check for terrain collisions once their origin is on the 'nodraw' side of the terrain. For collision optimization, probably?
In any case, I'd like to find a way to disable it for this specific object, or a workaround that still lets the object react to being partway inside the terrain some other way. Any ideas?
Answer by xxmariofer · Jan 20, 2019 at 08:34 PM
First, why would your object ever be at the same point of the floor?, it will be pushed out since 2, non trigger bodys should never overlap. second unity doesnt checks collisions with messhes but with colliders, a terrain behaves as a big flat box collider, so yes if your object somehow is inside the terrain, what is imposible unless is triggered, it would be called. Your problem is that you leave your object at the same level as the terrain and is not detting collisions or being pushed?
It's a terrain collider, not a plane collider, meaning it has hills and valleys.
The object is a sword attached to VR controllers which for the comfort of the user can move through walls. This also means it needs to be possible to at least detect the collisions from inside the walls.
The wall detection works perfectly with box colliders, but with terrain colliders it doesn't detect a collision if it spawns close enough to the terrain. I've tried enabling backface collisions - no change - and I tried increasing the collider's contactOffset, but increasing it that much also makes it collide nearly a meter off the ground.
If there's another way to check collisions with terrain that'd be fine too, I just need a way to handle the sword being close to hills.
Your answer
![](https://koobas.hobune.stream/wayback/20220612190121im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Car made from Different GameObjects and Empty GameObjects breaks on Collision with Terrain. 0 Answers
How to move an object on a terrain that will always stay on top of the terrain? 2 Answers
Bounce, gravity and velocity 1 Answer
Car will only turn right (& ignored collders) 0 Answers
[Help] Player stops moving when hitting wall diagonally 0 Answers