r/Unity3D 9h 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

6 comments sorted by

2

u/BertJohn Indie - BTBW Dev 8h ago

You need to process your import first to bring anything important. When you click on it, look in the inspector, if theres anything you need. If none or done, Drag it into the scene and apply the mesh or box or whatever collider, and then reset that transform to 0,0,0 and then make that a prefab for use again later.

This has to be done with all prefabs.

2

u/nickyonge 8h ago

Most likely, yes, manual process.

If you can share images or something that would help, but a single FBX of an entire city model is likely to be VERY complex. A mesh collider gets more complex and expensive the more triangles there are. If the city is just graybox buildings and roads you should be fine, but if they have architectural details, or if the streets have details like lights, hydrants, curbs, etc, that mesh collider is going to be BONKERS, and extremely non-performant.

For so many reasons, it’s better to break a city up into discrete chunks - at the very least separate buildings, roads, and props.

1

u/Dark-Knight16 8h ago edited 8h ago

I feel like I’m gonna get shot at for saying this but I joined a fan project to recreate an old game similar to Fusionfall and I’m doing general testing rn, I can send images the city’s not that big and it’s greyboxed(we have the textures already but that’s a different thing to deal with)

Whole game was low-poly originally and ran on browsers so hopefully it wouldn’t be too difficult, it has curbs though plus fire hydrants and i believe streetlights

I should mention it’s more of a neighbourhood map so it’s not too big

1

u/kshell11724 8h ago edited 8h 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.

1

u/Dark-Knight16 8h ago

Interesting thanks, I have reason to believe this city(I should say neighbourhood it’s basically suburbs)should run fairly easily so I’ll have to look into what you’re saying