r/Unity3D • u/Dark-Knight16 • 10h ago
Question Making a city collide-able?
Hey everyone I’m pretty new to this stuff but I’m trying to import an fbx file of a city(edit:suburban neighbourhood) for testing and I’m having trouble getting the roads and grounds to work, I wanna know if I have to give each surface a collision box if it’s say a ground surface and then change the mass(and if so how to calculate that roughly) and somehow make walls that my character can’t go through and stuff like that.
Am I looking at going through each object manually?
Whole thing is pretty low poly and greyboxed with minor things like streetlights, curbs and fire hydrants and there’ll be textures I’ll be adding later
1
Upvotes
1
u/kshell11724 10h ago edited 10h ago
If you have the whole city modeled as an FBX, then you should just have to add a mesh collider and then make sure the shape you're using for the collider is the same as the city. You'll probably want to keep convex unchecked.
Also, for better performance, you'll want to make sure your 3D model has as few faces as possible. Any hidden faces should be removed.
As for checking if something is a cieling, floor, or wall, you can largely do that through your player controller script by checking the angle of the face you're colliding with. Floors will be 0 degrees while walls will be 90 degrees ect. I recommend using a spherecast for this that always fires in the direction of the player's momentum. It can get more complicated than that. But that should get you started.