- Home /
There seems to be a collider when there shouldn't be
I already asked about this in the forum, but I wasn't sure where the best place for this was, so here is my question:
I have a sprite for the player that has a box collider and a Rigidbody2D attached, and a box collider attached to the seafloor, a cube. What I would like to happen is for the player to be able to continue swimming normally, but not through the seafloor.
This is not what happens, though. The player sprite plummets to the seafloor (it did not do this before I added the collider) despite the gravity scale on the Rigidbody2D being 0. After doing some research on this, I suspected that it was because it is occupying the same space as a collider in the background game object which I can see when I put the scene in wireframe view. The issue is that the game object that makes the background (EasyWater2D from the asset store) does not have a collider component at all.
Also, that might not even be the issue, because when I take away the background, the exact same thing happens despite there being no visible colliders. I am quite mystified. Any ideas on why this is happening and/or how to fix it?
Could you share your seabed collider? Also, why are you using a box collider ins$$anonymous$$d of terrain collider?
@TheSOULDev What do you mean by "share" the collider? I don't know how to use a terrain collider yet, but as of right now the seabed is completely flat so it seems like a box collider should be O$$anonymous$$.
If you have a problem with something, you should post on how that something is set up in the game. Therefore, you in this case you need to post how your collider is set up (preferably by a Unity editor screenshot) so we could see how it acts.
As for the terrain collider, as you are using a seafloor, which is terrain, you should learn how to use the terrain collider. It's simply a collider that follows the shape of a mesh, so it's fairly useful because of its precision and simple implementation. Although, because you use 2D you cannot use it, so in that case, you'd use a Polygon collider. Now, because you said you were using a cube, I HOPE you didn't use a 3D Cube collider for 2D object collision, because that simply won't work. If you're using a box collider, make sure that the edges are in the same Z coordinate as the player, otherwise they cannot interact.
@TheSOULDev Thanks for the pointers. I'll look into terrain colliders and make sure everything I'm using exists in the same number of dimensions.
Answer by TrumpetDude · Sep 01, 2017 at 11:21 PM
Well, despite my obvious lack of understanding when it comes to colliders, I managed to figure out what was causing the problem. For whatever reason, my camera had an edge collider on it that was hitting my ship's collider, and when I removed this, the problem was fixed. Thanks anyway though!
Your answer
Follow this Question
Related Questions
Unwanted results from 2D collisions? 1 Answer
Colliders in a wall jut out 0 Answers
Colliders not working when rotating 2 Answers
Multiple Stacked Colliders only register for single object 0 Answers