Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Combine multiple floor colliders into 1 large seamless one

Discussion in 'Physics' started by samnunn92, Sep 27, 2015.

  1. samnunn92

    samnunn92

    Joined:
    Oct 30, 2013
    Posts:
    4
    Hi all and thanks for reading.

    I am currently making a game in which the player rolls a ball around a course/maze with various obstacles etc. I plan to have quite a few levels so I have prefabbed a 1x1 tile with which to build the floor for the courses. Each tile has a box collider component. Aside from the performance hit from 30+ colliders when 1 would do the trick, I also get some weird behaviour whereby when the ball rolls across a 'seam' between 2 tiles it jumps, as if hitting a very small step. I assume that this is because the ball is colliding with the edge of the next collider (I've double checked y heights etc) and so I was wondering if there was a way to maintain the building block prefabs but combine the colliders once the level has been built? I've done some research and seen quite a lot on the internet wrt combining meshes in code - would I have to do that and then generate a new collider around the new mesh or is there a better way?

    Thanks very much!
     
  2. UsulPro

    UsulPro

    Joined:
    Sep 5, 2015
    Posts:
    2
    Hi!
    is your floor flat? If yes, maybe better to use one big plane with flat mesh collider instead of a lot of small ones (you can turn of Mesh Renderer so no effect on your graphic)
     
  3. samnunn92

    samnunn92

    Joined:
    Oct 30, 2013
    Posts:
    4
    Hi, thanks for replying! It is flat at the moment however I plan to implement curved surfaces at a later point so wouldn't be able to use flat mesh colliders for that. If needs be I suppose I can just make a custom floor & collider for each level but was really hoping to be able to combine the prefabbed tiles in some way as it will save me a lot of time.
     
  4. erandros

    erandros

    Joined:
    Sep 23, 2015
    Posts:
    6