- Home /
Collider Lifts me off Ground ??? And I'm afraid of heights !!!
Okay, I'm not really afraid of heights.
I have one friendly cube (or more) and I have some enemy cubes that move around on a terrain. But the enemies are double-secret cubes and they are invisible to my friendly cube...until they get close.
I'm trying to make them "visible" when they get inside a certain distance so I added a larger sphere collider to all my cubes and put a trigger on them...so when the larger sphere colliders touch, the dreaded enemy becomes visible.
However, my sphere colliders are not fully cooperating because the spheres totally encircle my cubes and because of physics, when the collider touches the ground, they elevate my cubes off the ground. I'm not sure how to set these sphereoid colliders so that my cubes can glide smoothly across the surface of my terrain.
Clarification: I have two colliders on my cubes. One is a cube collider, the same size as the cube, that detects collisions. The other is the "large spherical" collider (much larger) that acts as a trigger to make nearby units visible.
One thing I just found is a 2-D circle collider. Hmmmm. I'm going to test that to see if it works.
Anyone know how the trigger event would be affected if the two cubes were at slightly different altitudes?
Never $$anonymous$$d. I can't add a 2-D collider...I get a message that it "conflicts" with my box collider on the cube.
So much for that idea.
LoL. I didn't have "Is Trigger" checked. I just checked that and it may be just what the doctor ordered.
If this is the solution, I'm very sorry for taking up anyone's time. I'm testing it now.
Answer by Hanoble · Dec 14, 2016 at 06:20 PM
Make sure the IsTrigger bool is checked on the collider, which in code will mean you need to be using the "OnTriggerEnter" callback as well. Another thing you can do is set the layers if you want that trigger colldier to only interact with the player, as this will make it easier on the physics side as well.
Thanks. That indeed fixed the problem for me. I'm not sure how I missed that. I've been working with C# for some time but I'm fairly new to Unity.