- Home /
What's the obvious collider choice for prefab floor surfaces?
I'm building a dynamic tile/cell-based maze with collision detection on walls and floor. The floor won't be continuous, and if for example a pit trap is activated, the floor geometry would change on that cell. Besides, my floor texturing needs to change on a cell-by-cell basis. So I don't think a single large TerrainCollider (i.e. the usual method) is what I want.
So, for each floor tile I could:
-Use a small TerrainCollider created at runtime. I'm still not sure TerrainColliders are the thing as they seem to be geared to designing terrain, while I'm doing all the floor modelling in Blender to place as prefab instances.
-Use a BoxCollider. If so can it be zero-thickness, thus being a plane rather than a box?
-Just go for a MeshCollider. Thought this might be slower though.
What's the obvious choice here?
Answer by duck · Feb 02, 2010 at 01:12 PM
Unless you're actually creating a deformed (i.e. hilly) terrain, I don't think the Terrain Collider is suitable at all. As far as I know, you can't add a terrain collider to arbitrary objects - only Terrains, and you wouldn't want to use a separate terrain piece for each cell in your maze. The terrain system is designed to run fast when there's a single large terrain covering a wide area.
If your maze is grid-based, and each cell has a flat floor, I'd go for box colliders. Box colliders can't be zero-thickness, but they can be quite thin - and unless you can actually get to the underside of them, their thickness doesn't really matter, does it?
You could also try MeshCollider and see how it compares for speed, but box colliders are really pretty fast.
Why didn't you vote on this guys question, duck? I suppose that it is because you ran out of votes for today :P
I do upvote questions! - although sometimes it's only at a later date when I come back the the question to check for other answers and comments :)
Thanks Duck, this confirms what I was thinking. For now I've gone with $$anonymous$$eshColliders in that it makes creating pit tiles, tiles containing a set of steps etc. easier to implement using only bare meshes during initial prototyping. I'll be switching to box colliders once development has gone far enough to warrant some optimisation, as I can't see any instance where they wouldn't do the job I'd want them to do -- it'd just take a little more work.
Your answer
Follow this Question
Related Questions
Ignore parent Rotation 1 Answer
Collision between sambe objects with same Layer 1 Answer
Physics.BoxCast can't use out RaycastHit 0 Answers
On collisionenter name == redblock 0 Answers
For loop on collision (two hit kill) 2 Answers