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

(Minecraft Block) How to check if an Object has support

Discussion in 'Scripting' started by boco, Aug 30, 2014.

  1. boco

    boco

    Joined:
    Dec 7, 2010
    Posts:
    373


    On my video I have blocks here and they connect just fine but I was wondering how I would handle blocks having a support system that goes to the ground. I've tried making the blocks have rigid bodies and connecting to one another but this leads to severe performance issues. I'm using Photon Networking solution so anything to help with this is greatly appreciated. Thanks.
     
  2. zeman97

    zeman97

    Joined:
    Sep 22, 2012
    Posts:
    53
    You could assign a "support" number to each block and use an algorithm to calculate a block's current support value judging from its neighbors, and then if that support number falls too low, turn on the blocks rigidbody so that it falls to the ground.
    Example.jpg

    Using this method of keeping rigidbodies disabled, you can save a ton on physics until its actually needed.
     
  3. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    You cannot 'Turn Off' a rigidbody you can only add or remove.

    As far as the OP I am not sure I understand...
     
  4. boco

    boco

    Joined:
    Dec 7, 2010
    Posts:
    373
    interesting concepts here... I will have to look into that
     
  5. boco

    boco

    Joined:
    Dec 7, 2010
    Posts:
    373
    Working on the support system next I will post a video and a big thanks for the idea... I'll let you know if it works :D
     
  6. zeman97

    zeman97

    Joined:
    Sep 22, 2012
    Posts:
    53
    Awesome! I hope it does! I remember a while back I was trying to work with voxels and I just could not optimize my system enough for it to be playable, but I still love the idea of constructive terrain, it seems too many games these days feature destructive terrain...
     
  7. boco

    boco

    Joined:
    Dec 7, 2010
    Posts:
    373
    Ha I don't know if you noticed but I'm avoiding terrain being messed with in that way really. Terrain is static but castles and all that are built similar to minecraft (blocks) and so far the gameplay is getting there zombies can now tear down walls, attack players, etc but I have a few issues/bugs to work out as now we have an issue where zombies are dying on one player's client but not dying on all clients and still sending/attack information basically think ghost zombies.. you can hear them and you can get hit by them but only a single player can kill them.. would be a cool feature for like ghost mobs or something haha only one player can actually see them/kill them lolz...
     
  8. zeman97

    zeman97

    Joined:
    Sep 22, 2012
    Posts:
    53
    Hahahaha you could have a variable that determines how demented you are and you are attacked by hallucinations essentially :p