Search Unity

[RELEASED] uConstruct - Fully generic, socket based runtime construction system

Discussion in 'Assets and Asset Store' started by ElroyUnity, Oct 17, 2015.

  1. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hi Elroy,

    I'm facing a very wirred behaviour with uConstruct :

    Basicly i'm having 2 Buildings placed nearby each other (no snapping...) :

    * A fondation wich is already placed in my terrain with the following specs : Batched in a Group (lets call it Grp1) and with a Material "Mat1".
    * A wood Fence wich is also already placed in my terrain : Bateched in another Group (Lets call it Grp2) and with a material "Mat2".

    What i'm trying to do, is the merge the wood fence building in the same batched groupe as the fondation (for optimization).

    Here is my code :

    Code (CSharp):
    1.  
    2. myWoodfence.batchBuilding = false;
    3. myFondation.buildingGroup.AddBuilding(myWoodfence);
    4. myWoodfence.batchBuilding = true;
    5.  
    The wood fence is moved after that to the same buildings group with the fondation but since it have a different material than the fondation i'm having the fondation material applied to the wood fence. It's seems like the batched group doesn't detect the materials differnce and does not generate a new Group Batched Collider.

    After some debuging, i noticed that PopulateBatchedFilters detect that we have now 2 filters (the fence and the fondation) but the batchData.Count (in the Batch function) still return 1 (i gess for 1 material ?) wich result in single "Group Batched Collider".

    I'm pretty sure i'm doing something wrong, but i've been into this for days now ... and its driving me crazy :)

    Any help will be much appreciated ;)
     
    ElroyUnity likes this.
  2. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Uhmm I see, definitely an interesting one.
    Will have a look at that issue this week, probably something on my end ;)
     
    amynox likes this.
  3. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Thank you very much ;)
     
    ElroyUnity likes this.
  4. txzeenath

    txzeenath

    Joined:
    Sep 26, 2016
    Posts:
    6
    With my current usage, I need all objects to be re-parented when snapped to a socket. I did this by overriding BaseSocket's BuildingSnapped method. But I noticed the BaseBuildingGroup automatically makes all objects in the group a direct child when added.

    Just curious if I'll need to re-write a lot, or if just overriding AddBuilding will work. I'm not sure how much of the system relies on hierarchy.
     
    ElroyUnity likes this.
  5. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Oh the system doesnt relay on hierarchy at all, just override the add building and it should be fine :)
     
  6. txzeenath

    txzeenath

    Joined:
    Sep 26, 2016
    Posts:
    6
    Code (csharp):
    1.  
    2.         public virtual BaseUCSaveData Save()
    3.         {
    4.             BuildingGroupSaveData data = new BuildingGroupSaveData();
    5.             data.GUID = "";
    6.             data.buildingsData = new List<BuildingSaveData>();
    7.             BaseBuilding building;
    8.  
    9.             for(int i = 0; i < groupBuildings.Count; i++)
    10.             {
    11.                 building = groupBuildings.ElementAt(i);
    12.  
    13.                >>>>  data.buildingsData.Add(new BuildingSaveData(building.transform.position, building.transform.rotation,
    14.                     building.placedOn == null ? -1 : building.placedOn.uid, building.health, building.prefabID, building.uid));
    15.             }
    16.  
    17.             return data;
    18.         }
    19.     }
    Somehow the building became null during saving right here which apparently corrupted the save file (serialization error). I tossed in a null check to be safe. But I have no idea how to reproduce it lol.
     
    ElroyUnity likes this.
  7. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Uhm thats strange, did you do something unusual like destroying a building manually with GameObject.Destroy or smth?
     
  8. txzeenath

    txzeenath

    Joined:
    Sep 26, 2016
    Posts:
    6
    Just force quit the application (while in editor). It came back saying building was null. And then on reload had a serialization error. I have no functions at the moment that call destroy on uConstruct objects.

    It's kinda a freak accident since I've done it hundreds of times before with no issue.
     
  9. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Really strange... rewriting the save and load system anyways for the new version so probably no point of me looking at it as of now, could you wait for the new version or is that super urgent?
     
    julianr likes this.
  10. txzeenath

    txzeenath

    Joined:
    Sep 26, 2016
    Posts:
    6
    Nah, not a problem. It's never occurred before and even if it happens again, nothing in my saves is worth keeping. Just developing the systems around building right now.
     
    ElroyUnity likes this.
  11. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hello Elroy,

    Any advancement on my issue ?

    Thanks
     
    ElroyUnity likes this.
  12. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Didnt have time to look at it yet, sorry. Will take a look soon :)
     
    amynox likes this.
  13. tra2002

    tra2002

    Joined:
    May 11, 2011
    Posts:
    142
    With a few custom conditions and some head scratching was able to have a building system more like Ark: Survival Evolved and Conan Exiles.

    I have purchased a few construction packages but this one is the only one worth every cent of the price.

     
  14. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Thank you very much for your kind words!
    Happy you were able to solve your problems and thanks for sharing your solutions, will implement them into the next version :)
     
    tra2002 likes this.
  15. errandfox

    errandfox

    Joined:
    Apr 22, 2015
    Posts:
    42
    Hi, I'm getting errors when using photon - have tried with the photon cloud demo included and still have the same problem.

    the error is on right clicking a building - InvalidCastException: cannot cast from source type to destination type.

    here is the full error:
    InvalidCastException: Cannot cast from source type to destination type.
    uConstruct.Extensions.PCloudExtension.CreateNetworkedBuilding.Deserialize (System.Byte[] data) (at Assets/uConstruct/Scripts/Core/Extensions/Extensions/Photon/Integration/Core/PhotonCloudEntitiesManager.cs:295)
    uConstruct.Extensions.PCloudExtension.PhotonCloudEntitiesManager.HandleEvents (Byte eventCode, System.Object content, Int32 senderid) (at Assets/uConstruct/Scripts/Core/Extensions/Extensions/Photon/Integration/Core/PhotonCloudEntitiesManager.cs:76)
    NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2514)
    ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
    ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands ()
    ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
    PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)

    Do you have any ideas?
     
    ElroyUnity likes this.
  16. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Hey,
    Will take a look hopefully today/ tomorrow and let you know :)
     
  17. whatbus2000

    whatbus2000

    Joined:
    Nov 21, 2014
    Posts:
    65
    Thanks ShinfoK. This helped me too
     
  18. whatbus2000

    whatbus2000

    Joined:
    Nov 21, 2014
    Posts:
    65
    has anyone successfully integrated UFPS Uconstruct and Inventory Pro. I am having troubles. I have ufps and Inventory Pro sorted out okay but cannot place a building even though I have it setup correctly (I think). Can uConstruct be setup with Hero character in UFPS?
     
    Last edited: Jun 12, 2017
    ElroyUnity likes this.
  19. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Just seen your email! answered it :)
     
  20. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hello Elroy,

    Sorry to insiste but it has been more than 20 days and this issue is really annoying !!!

    Any advancement please ?
     
    ElroyUnity likes this.
  21. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Still didn't get the chance to look at it :( super busy lately...

    Will try my best to get you a fix on the weekend
     
    amynox likes this.
  22. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi, Elroy I'm thinking use capsule or sphere colliders for the sockets, but the default socket setting only have box colliders, how can I make other shapes of the sockets?
     
    ElroyUnity likes this.
  23. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Not possible atm, will be available on the next big update.

    Or, you could add a sphere collider (or w/e) add a socket component and disable "use physics"

    That should work :)
     
    Harekelas and Stormy102 like this.
  24. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Ok, I see, not sure if using unity's physics will cause some performance issues.
    Since I know you are focused on uNature's next update, I assume uConstruct's update may not be around anytime soon, and the collider shape is not a primal issue I need to solve right now. So I'll keep the box colliders. ;)
     
    ElroyUnity likes this.
  25. MaskedGibbon

    MaskedGibbon

    Joined:
    Mar 26, 2016
    Posts:
    10
    I'm getting the following error when attempting to place a foundation tile that I made using the CubesDemo blueprint "Ex" button.

    IndexOutOfRangeException: Array index is out of range.
    uConstruct.Conditions.TerrainModificationCondition.HandleTerrainModifications () (at Assets/uConstruct/Scripts/Core/Conditions/BasicConditions/TerrainModificationCondition.cs:190)
    uConstruct.BaseBuilding.PlaceBuilding () (at Assets/uConstruct/Scripts/Core/Buildings/Base/BaseBuilding.cs:645)
    uConstruct.Demo.BuildingPlacer.PlaceBuilding () (at Assets/uConstruct/Scripts/Demo/BuildingPlacer.cs:463)
    uConstruct.Demo.BuildingPlacer.Update () (at Assets/uConstruct/Scripts/Demo/BuildingPlacer.cs:331)


    It has conditions for flattening ground (I think...) and removing grass.


    Any clue as to why this might be happening? This is on Unity 5.6 in the CubesDemo level, but with my foundation piece replacing the default.
     
    ElroyUnity likes this.
  26. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Thats strange.
    Can you try and copy the values for that condition from the foundation on the demo?
     
  27. MaskedGibbon

    MaskedGibbon

    Joined:
    Mar 26, 2016
    Posts:
    10
    The condition is the same (except that it's disabled in the foundation from the demo by default).

    I've been attempting to follow your blueprint tutorial without much success (as I've said before, the interface is different in the version used in the tutorial video). Usually what happens is the model I'm attempting to "export" ends up being tiny within the confines of the "socket" (not sure if that's what you'd refer to it as). This occurs on Unity 5.6 using nothing but uConstruct and 3DForge Village Interiors in a new project.


    Steps to reproduce:

    1) Open the CubesDemo scene.
    2) Create the layers "Building" and "BuildingSocket".
    3) Open the uConstruct blueprint system and click "Ex" on "3DForge_Interiors\Field: Foundation\Building: Interior_Foundation".
    4) Choose a bed from the 3DForge set (I was trying floor tiles previously).
    5) Drop the bed into the scene (it doesn't get auto created like it does in the video).
    6) The bed hasn't been stretched like in the video.
    7) Set "FPSController\Building Placer\Buildings\Element 0\Buildings\Size" to "2" and drag the new prefab onto "Element 1".
    8) Run the game and attempt to place the new "Foundation", I get the previously mentioned error, and it fails to save.

    I was trying this with floor tiles previously and getting the same result. I couldn't get the tile to occupy the whole "socket" (it does stretch if I use the CubesDemo foundation blueprint "Ex" button - what's the difference?)

    Regardless, when I place the objects in the scene using the DemoPlayer script (adding my new prefab to the building list), I get the error I reported earlier.


    The default CubesDemo floor, etc work, but I can't get 3DForge objects to work for the life of me.


    What is the best video to follow for the workflow of taking a 3DForge object and using it with the DemoPlayer script? Because I feel like I must be missing some steps and none of the videos I've seen so far seem to demonstrate the whole process. I've read the PDF that comes with uConstruct, but it doesn't have a step-by-step for how to do this (the 3DForge one is also out of date, and again doesn't guide you through the entire process).


    Is uConstruct 2 going to be a free upgrade for existing owners of uConstruct? Maybe I'd be better off waiting for that if so, because this isn't really urgent (purely hobbyist at the moment).
     
    ElroyUnity likes this.
  28. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Hey,

    Uhmm, I see, well if the blueprints are bugged for you there's another easy solution for setting up buildings.

    Drop a tile from the 3DForge objects into the scene.
    Then drop the foundation prefab from the cubes demo.

    Place them both on 0,0,0 and scale them to be exactly the same.
    Then create a base building component on the tile and copy the components from the foundation and copy paste the sockets and conditions (just ctrl + c and ctrl + v)

    and then make the tile a prefab, click "Add to prefab DB" and you should be done.

    (sounds complicated but its actually rather fast and many use that approach when the blueprints arent working :))
     
  29. MaskedGibbon

    MaskedGibbon

    Joined:
    Mar 26, 2016
    Posts:
    10
    I think there might be a couple of steps missing from that.

    Set the base building type (to "Foundation" in this case).
    Set the layer of the new foundation to "BuildingSocket".
    "Batch Building" also isn't checked by default.


    Also, it's not working... At one point all the sockets on the new foundation got disabled. I fixed that, then I was able to place the new foundation again, but it doesn't save or load like the demo foundation does. I can't see a difference between them except for the scaling of the mesh and the collider.


    Right... I seem to have stumbled upon the answer... as I was typing this I called your "Initiate Prefabs Update" and now the foundation appears to be saving and loading correctly.

    When and how often does this have to be called? I had already given it a prefab Id, but now (post update) it has changed from 34 to 8. Your documentation doesn't seem to mention this btw, though the prefab video does.


    Maybe I had multiple prefabs using Id 34? This was a new foundation that I clicked "Add Prefab Id" for.


    I can probably use the CubesDemo blueprint export now that I seem to have identified what the problem was (at least with the saving/loading).
     
    ElroyUnity likes this.
  30. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Uhmmm you shouldn't assign IDs more than once, just make sure to not copy paste the base building component (Seems like I said you should for some reason in the first comment) and then it will make you assign a unique one :)
     
  31. IrishDev

    IrishDev

    Joined:
    Jul 18, 2012
    Posts:
    50
    Hi Elroy,
    I will be attempted to intergrate UConstruct with UFPS and Inventory Pro. Whatbus2000 asked a similar question not so long ago but you responded via email to him.
    Could you please let me know how this can be done and what issues (if any) to expect?

    Thanks
     
    ElroyUnity likes this.
  32. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Hey,
    Wont work possibly.
    You can integrate uConstruct + UFPS/ uConstruct + UFPS + Photon Cloud and also uConstruct + Inventory Pro.
    But individually. There's no support for them together.

    The code is there tho, it will require some coding from your end to mix the scripts tho.
     
  33. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Use the UContruct and Inventory Pro Setup :D

    Then just look how the Inventory building is setup and add to the Inventory filters at the bottom to allow for UConstruct items.
     
    Last edited: Jul 21, 2017
    IrishDev, Tethys and ElroyUnity like this.
  34. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Ahh thanks for the suggestion, was looking for something like this for our project, now we have a solution. :)
     
    ElroyUnity likes this.
  35. IrishDev

    IrishDev

    Joined:
    Jul 18, 2012
    Posts:
    50
    Thanks IlJIMBOBII
    I thought that there was more to it.
    Currently having issues with Inventory Pro and UFPS that are unrelated to this
     
    ElroyUnity likes this.
  36. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Absolutely!

    Thank you very much Jimbob!!
     
  37. IrishDev

    IrishDev

    Joined:
    Jul 18, 2012
    Posts:
    50
    Thanks guys, Yes I missed the entire "Integrations" folder.
    Thanks for the quick responses :)
     
  38. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    Hey i buy today uConstruct and i install into my main Project but uConstruct is not working the demo is not working and when im setup self not working the controls show nothing http://prntscr.com/g2jgpz

    some ideas ?
     
  39. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Quick question about placement sensitivity/parameters. Our project takes place on very rocky and uneven terrain. Its possible to flatten the terrain to a degree but there are no flat spots. Having a real hard time with placement because of this. Briefly took a look around and didn't find it - can someone refer me to where the placement parameters are set? I want to make it less picky about flat terrain or whatever it is that keeps causing it to stay in the red when trying to place on a legitimate surface. Thanks in advance.
     
  40. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi,
    I'm trying to add a function to uConstruct's sockets.
    I'd like to disable the overlapped sockets to only remain one of them.
    Here is my thoughts: when I put one building block down, I'll check every socket on this building and detect collisions with other sockets for each one. Then compare the position of these collided sockets to the one we are checking. If it can find a collided socket is too close(say distance shorter than 0.05) to itself then disable this socket.

    Now the problem is I don't know how to realize it through uConstruct's physics system, any suggestions about the coding details of it? :)
     
  41. Stagg

    Stagg

    Joined:
    Dec 19, 2013
    Posts:
    2
    I'm working on a castle building sim and had a few questions. I might be missing it, but is there a way to draw the gameobject of a building you're snapping too? For example, I place a tower and then a few walls. I then want to go back and replace a wall section with a tower/gate. How would you recommend doing this?

    I originally tried using a condition to destroy the wall section once I placed the gate, but I couldn't get it to work. Any suggestions?
     
  42. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Thanx Elroy for your help :D
    This is to only place one item at a time with Inventory Pro, like in the game Ark

    In UconstructInvPlacer I added a bool IsPlaced = false; and added to onEquip and onDeEquip
    Code (CSharp):
    1. public virtual void onEquip(GameObject prefab, BuildingInvEquipItem item)
    2.     {
    3.         IsEquipped = true;
    4.         this.currentPrefab = prefab;
    5.         this.item = item;
    6.  
    7.         CreateBuildingInstance(prefab);
    8.     }
    Code (CSharp):
    1. public virtual void onDeEquip()
    2.     {    
    3.         currentPrefab = null;
    4.         item = null;
    5.  
    6.         DestroyCurrentBuilding();
    7.         IsEquipped = false;
    8.     }
    Then in PlaceBuilding I added
    Code (CSharp):
    1. public override void PlaceBuilding()
    2.     {
    3.         if (item != null)
    4.         {
    5.             base.PlaceBuilding();
    6.  
    7.             if (item.Place())
    8.             {
    9.                 this.item = null;
    10.             }
    11.  
    12.             if (IsEquipped == true) {
    13.                 InventoryPlayer m_InvPro = PlayerManager.instance.currentPlayer.inventoryPlayer;
    14.                 var Char = m_InvPro.characterUI;
    15.  
    16. //This is where your slot for UConstruct Build Item is located, e.g head, arms, legs, weapons...
    17.                 var Item = Char [10].item as BuildingInvEquipItem;
    18.  
    19.                 Char.UnEquipItem (Item, false);
    20.             }
    21.         }
    22.     }

    I have one more question XD. I'm wondering if I can for eg... I have a wood wall placed and I want to place a stone wall on top of it and the wood wall will destroy, like in the game Ark.
    I'm wondering if its possible and how to go about it.

    Thanx man Amazing System :D
     
  43. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Does anyone know how to make the item / wall etc... appear in front of you even if it cant snap it will show a preview and turn green when can place. at the moment it seems the preview only show if it hits the socket collider.

    Thanx
     
    Harekelas likes this.
  44. Carterryan1990

    Carterryan1990

    Joined:
    Dec 29, 2016
    Posts:
    79
    Hey there, awesome asset! Im having trouble integrating with the ufps hero which is the first and third person character from ufps. In the ufps files for your asset, there is only the demoplayer which is a first person player. Am i missing something? Thanks again!
     
    ElroyUnity likes this.
  45. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Uhmm it should be exactly the same, only difference is in the BuildingPlacer (in your player) change the ray origin from center to mouse position :)
     
    Carterryan1990 likes this.
  46. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Bump up this question, one of the downside I tried to fix but failed of uConstruct
     
    ElroyUnity likes this.
  47. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Oh sorry forgot to reply to that one. Anyways, the trick I use is go to your terrain/ surface, go to the BaseSocket component and toggle "isHoverTarget" on :)
     
    llJIMBOBll likes this.
  48. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Well call me stupid, it's that easy :D Thank you so much man!
     
    ElroyUnity likes this.
  49. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Hi Mate, I'm having the same troubles seems to do with bodyanimator script, did you find a solution? Cheers
     
    ElroyUnity likes this.
  50. ElroyUnity

    ElroyUnity

    Joined:
    May 20, 2015
    Posts:
    1,588
    Hey!
    To be honest, not yet as I haven't been able to reproduce it at all.
    Do you have reproduction steps? if so, please let me know and I will send a fix asap!