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. Dismiss Notice

Help me please i have problem whit mesh collider

Discussion in 'Editor & General Support' started by branek42, Nov 4, 2014.

  1. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    Heloo i have problem whit mesh collider on big castle .fbx and verry lags.

    Game is for android and is unplayable

    Verry Thank you for answering
     
  2. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    How many polys is it? Is it very detailed?
     
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,071
    Mesh colliders are very expensive to use and will eat up your performance quickly. Especially for mobile devices. You really shouldn't use them unless you have no choice.
     
  4. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    yes Is it very detailed Castle is also from the inside
     
  5. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    Ryiah What would be a replacement for the mesh collider??
     
  6. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    That is exactly your problem.... You're best off breaking it into Sections and applying basic colliders to it to get as close to a good fit as possible...

    I only use mesh colliders for abnormal objects like Rocks that players can walk on. Otherwise I try my best to leave Mesh Colliders alone.

    If you didn't have many polys I'm sure that would be fine.
    But as Ryiah said, they eat performance quickly.
     
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,071
    Replace the mesh collider with multiple simple colliders such as box colliders.
     
  8. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    Box collider not possible give on castle because is verry complex
     
  9. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Like I said, break it into multiple pieces.

    or add 10000 box colliders to one object if you wish, but that's no better than a mesh collider.

    We're just trying to help guide you in the right path.
     
  10. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    N1warhead I am a beginner and I did not know that it will be problem
     
  11. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    wrote i have this script but also so meshcolider lags

    castle is riven on more part but no enough


    var object1 : GameObject;

    function OnTriggerEnter (other:Collider) {

    if(other.gameObject.tag == "Player"){
    object1.GetComponent(MeshCollider).enabled= true; // make very sure

    }}
    function OnTriggerExit (other:Collider) {

    if(other.gameObject.tag == "Player"){
    object1.GetComponent(MeshCollider).enabled= false; // make very sure


    }}
     
  12. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Exactly how many polygons are there?

    Otherwise I don't know what else I can say or do other than learn how to optimize your models.
    Keyword ("Learn")

    One of the easiest ways is learn to learn "Bridging"

    Or go to your 3d modeling program (if you have one) - you make it sound like you went to turbosquid and downloaded a caslte.
    But goto a 3d modeling program and look for Optimize modifiers. They can help a lot as well in optimizing modelings with fewer polygons.

    Scripts aren't gonna help you in the case, the model is what the model is, it's a lot of Geometry according to how you make it out to be. It's not gonna change that the model is extremely detailed and it needs to be less detailed.

    Learn to optimize it or get another model with less detail or learn to break them into pieces and still use fewer details with Geometry and learn to how to use Normal maps for the details and Displacement maps, etc.
     
  13. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    Thanks I will learn him divide or I put into castle 100 box colliders :)


    sorry me English is weak
     
  14. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Your English is fine buddy.

    Just understand, the less colliders you have the better. But likewise, it's not just colliders.
    If your model has WAAAAY to much detail that is enough to crash anything.
     
  15. branek42

    branek42

    Joined:
    Oct 10, 2013
    Posts:
    76
    it is clearly :) but as build big city , skyscrapers ? also their divide?
     
  16. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    If you're going mobile you want to keep the costs of everything down, so yes, you want to keep it as low as possible but still high enough to look good. But that's where Normal maps come into place to give it that High detail look.

    All i can reallly say is start learning and you'll get it. It won't happen over night, but it will come to you eventually with dedication.
     
  17. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,613
    Breaking your mesh up into smaller pieces should improve performance, even if you don't convert each individual piece into a box collider (or other primitive shape). Breaking the mesh into pieces will allow only those triangles which are actually near your object to be tested for collisions.
     
    landon912 likes this.