Search Unity

[RELEASED] Snap-and-Plug: join anything to anything

Discussion in 'Assets and Asset Store' started by a436t4ataf, Sep 15, 2014.

  1. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Updated the website ready for version 2:



    ...and another video for one of the how-to tutorials:

     
  2. Bitcloud

    Bitcloud

    Joined:
    Feb 25, 2014
    Posts:
    8
    Hi Mate, just what I'm looking for.

    I'd love to get on the beta for 2.0 if possible. Needing to build some in game construction!

    cheers
    Lachlan
     
  3. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Email me (address on website - http://snapandplug.com ) your invoice number (on asset store, click on Credit Card payments, and you get an invoice number for each thing you bought) and I'll send you the current build.

    Only thing I'm holding back on for launch right now is I want to clean-up the demo scenes. Right now, they're too messy to include at all, IMHO. But it's a lot of work to improve them.

    Maybe worth launching without, and make them available as a later DLC?
     
  4. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    6 months after the beta, and 2 years since the first release (!), version 2 is finally live.

    Major changes:

    • Works in-game! Included: a Cars demo (with full source) that shows how you can do the snapping in-game, and add mouse-support etc.
    • Customization made easier: now you can drop/drop SnapJoints from the Project window onto each Socket, and write your own rules to make custom SnapJoints
    • Multiple demo-scenes: From the very simple (3 objects) up to the very complex (playable game), all with full source code.
    • Bug fixes: lots of edge-cases, some rare, some less rare

    As promised, upgrade is free for all version 1 users.

    NB: some of the new features are incompatible with the v1 code - if you have difficulty upgrading, PLEASE EMAIL me! None of the betatesters had problems, but if you have a particularly large project, I will help you get it converted.
     
  5. j0hnbane

    j0hnbane

    Joined:
    Jul 2, 2014
    Posts:
    20
    Hello there!

    I've purchased your asset a little bit ago and finally got a chance to play around with it.

    It seems to work fine with a mouse, but I was attempting to use it with an HTC Vive and it will not snap. Is there something I can do to work this in?

    Thanks!
     
  6. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    @j0hnbane - I don't have a vive to test with, but email me (should be on the website Contact page) and we can work through it in more detail. I have a rift at work, I can try borrowing one of those and recreating whatever issues you're having.
     
  7. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Version 2.1 is in beta testing now. Main changes:

    1. FIXED: sometimes when you try to move or rotate an object in Editor, Snapandplug steals the mouse and starts snapping it instead
    2. FIXED: If you parent a SnapPiece to another SnapPiece, Snapandplug gets confused about which one is which (NB: requires modifying existing projects: I'm currently making an auto-update script that will upgrade your project automatically)
    3. Improved rendering of snap-handles in editor, and their sizing
    4. Added some extra API calls to make it easier to do snapping from your own scripts
     
  8. j0hnbane

    j0hnbane

    Joined:
    Jul 2, 2014
    Posts:
    20
    Will do. Did a complete wipe on my main machine and I'll have it back up this weekend. I'll put together a video for you and some details.

    Thank you
     
  9. ScottPeal

    ScottPeal

    Joined:
    Jan 14, 2013
    Posts:
    61
    Hi Adam,

    Do you know if the version in the store will work with Unity v5.5 beta? We are using that version.

    Also can we use snap groups to prevent users from attaching parts to wrong slots. For example, trying to attach a leg to an arm slot?

    Thanks
     
  10. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    I haven't tried it yet, but should be fine. Any probs - email me and I'll patch as needed!

    Yep, that's exactly what SnapJoint was created for, and how it works. c.f. the PDF docs on website (I'm planning an update to make this a bit easier to use, but it'll take me a few more months I think)
     
  11. Luke_TyWalker

    Luke_TyWalker

    Joined:
    Nov 4, 2016
    Posts:
    1

    I have the same interest. I bought the asset thinking since it worked in game, it would be easy to get it working with the Vive. I guess I am not much of a programmer as I can't really see how to make it work in game much less work with the Vive.

    Did you guys get it working? Would you share with me how you did it?
     
  12. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    I haven't had a response from @j0hnbane yet, and no-one else has reported problems with VR sets - so, same thing: send me details of what you've tried, what happened, what you expected to happen, etc, and I can look into it.

    Also, in one of my own game-projects, I've been experimenting with making a rich in-game GUI to go on top of SnapAndPlug for mobile and desktop. I don't know how many games it would be good for - every game and game designer wants a different, incompatible, in-game control system - but I'm trying to make it generic and reusable as possible.

    It's taking a lot of time to do (many edge-cases to support, many bugs to test, lots of messing around with input-systems, etc), but if there's enough interest I'll look at adding it to S+P in future. The way it's going, I'd have to push the price up for new users, which I'm a bit worried about (I don't want to make it too expensive!), but it's not a deal breaker.

    ...the biggest issue is: can I get it fully working, and generic enough to re-use in different games! :)
     
  13. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    PS: if anyone wants to alpha-test it, email me - although it might be a while before I'm ready to alpha test (and it would NOT be good enough to use in a real game - there's too much missing right now)
     
  14. ScottPeal

    ScottPeal

    Joined:
    Jan 14, 2013
    Posts:
    61
    Just heads up of issue in latest beta 5.5.0b10

    InvalidOperationException: This cannot be used during play mode.
    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty (Scene scene) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorSceneManagerBindings.gen.cs:147)
    UnityEditor.EditorApplication.MarkSceneDirty () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.deprecated.cs:95)
    SnapAndPlugEditorScripts.EditorSettings.UpgradeScene (SnapAndPlug.SnapAndPlugScene sceneData, Version vTo)
    SnapAndPlugEditorScripts.EditorSettings.ForceReloadSettings ()
    SnapAndPlugEditorScripts.EditorSettings.RunOncePerReload ()
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:197)


    Also a information message:

    SnP: after internal force-reload of data, is saved instance still null ? False ... asset path = Assets/Plugins/SnapAndPlug/Resources/SnapAndPlug-settings.asset
    UnityEngine.Debug:Log(Object)
    SnapAndPlugEditorScripts.EditorSettings:ForceReloadSettings()
    SnapAndPlugEditorScripts.EditorSettings:RunOncePerReload()
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
     
  15. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Thanks - sorry about that, the auto-upgrade code should be disabled in runtime, I must have missed one of the "if UNITY_EDITOR" lines. I'll submit a patch to Asset Store next week.
     
  16. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    @ScottPeal - something odd here; what you've seen should be physically impossible. I believe it's a bug in Unity 5.5 - it's loading an Editor-only script at runtime (which Unity guarantees it will never do, by definition).

    I'm going to add some defensive code to protect against this anyway, but if it triggers in the final build (after 5.5 leaves beta) it's probably something we should report to Unity. If you can put together a reproduction case and/or submit to Unity that would be great.
     
  17. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Hi, this looks interesting.. does it have a save system or a way to send all object transforms to a save file so when you load up your scene, its there again? Presuming you have a GUI at runtime to do this?
     
  18. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    @julianr it's fully integrated into Unity, so it works the same as any change you make with the built-in Editor controls. If you snap things, the scene becomes Dirty and you'll be warned you have unsaved changes if you try to quit Unity; when you restart, everything is exactly as you left it.

    For runtime, because it's correctly integrated with Unity, any code you're using to save your gameobjects already should work 100% the same with SnapAndPlug - my code is implemented as standard MonoBehaviour/Components attached to your GameObjects.

    (I did it this way specifically so that we wouldn't need to do anything different/special to use existing featuers like you mention).

    If you get any problems with the above, let me know. There were no reported bugs in this area during the last couple of betas, so I believe those bits of code are very stable.
     
    julianr likes this.
  19. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    potential buyer here

    Any update regarding HTC Vive compatibility... from what I've seen to date it requires a UI to initiate each object..
     
  20. j0hnbane

    j0hnbane

    Joined:
    Jul 2, 2014
    Posts:
    20
    I didn't realize I had some responses to me in this thread, my apologies.

    I did not get it working with the Vive, but I also haven't tried it again since about early November. I decided to learn C# and made my own solution that works for my game's needs. When I get more time, I'm hoping to come back to this and be able to look at it more. Would be a nice feature in future projects.
     
  21. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    I'd love to fix it, if anyone can tell me what's actually "wrong" - I don't have a Vive to test with :(.

    My guess is it's something very simple, like ... maybe I'm using a part of Unity that ignores Vive inputs, and so it needs an extra line of code to check for Vive instead of mouse.

    All the source code for the in-game stuff is there for you to tweak, so you could easily take that and experiment.

    If you're trying to use the Vive in-editor, and that's not working ... that would be a harder problem. But again, I don't know what the problem is so I cant' do much about it :(.
     
  22. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Meanwhile, I've been working on this (all in-game, not editor):



    A few people have asked me to write a full in-game snapping system, so I'm experimenting. But it's basically a whole extra asset. My first version worked great for top-down RTS games, but useless in FPS (because they have different UIs, and what works in top-down breaks in FPS). Not sure what I'll do with this yet, but it's quite fun to play with.
     
  23. duesentrieb66

    duesentrieb66

    Joined:
    Jan 2, 2017
    Posts:
    1
    Hello,
    I am completely new to unity. Try to run your "simple example" but get this error. Can not grab or move any cylinder. Motor/Wheel example is working.

    Unity version 5.5.0f3 Personal

    How can I fix this?
    Thanks, Duesentrieb

    InvalidOperationException: This cannot be used during play mode.
    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty (Scene scene) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorSceneManagerBindings.gen.cs:147)
    UnityEditor.EditorApplication.MarkSceneDirty () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.deprecated.cs:95)
    SnapAndPlugEditorScripts.EditorSettings.UpgradeScene (SnapAndPlug.SnapAndPlugScene sceneData, Version vTo)
    SnapAndPlugEditorScripts.EditorSettings.ForceReloadSettings ()
    SnapAndPlugEditorScripts.EditorSettings.RunOncePerReload ()
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:197)
     
  24. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    @duesentrieb66 this appears to be a bug in Unity 5.5 - Unity is doing something they promise never to do :(. The 5.x.0 versions of Unity tend to have a lot of bugs, so they might change/fix this in 5.5.1.

    If you email me I'll send you a patched version you can use until I update the Asset Store version. adam.m.s.martin at gmail.com

    (The new version I'm working on has some other new features that aren't fully tested yet, so I don't want to push them to the asset store in case they cause problems with existing projects!)

    @ScottPeal - ditto: if you're still seeing this issue, email me and I'll send you a private build which has the workaround added.
     
  25. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    UPDATE: three rounds of patching later, all now fixed, and the new update (adds integration with Unity Physics Joints) is almost finished.

    I aim to get this finalised and submitted to Unity tomorrow. The physics stuff is pretty cool - lets you snap physics-objects together, and it auto-creates the necessary joints.
     
  26. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Version 2.2.0 is now with Unity, waiting for approval. Should appear in the Asset Store by the end of the week.

    Here's the new tutorial video for the new Physics-integration:



    I'm using this in a "build-your-own-physics-racer" game at the moment, it's great fun.

    NB: this release only supports Unity 5.4.0 upwards (5.4.0, 5.4.1, 5.4.2, 5.4.3, and 5.5.0) - if you're still on 5.3 or older, email me and I'll send you a beta build for Unity 5.3 / 5.2.
     
  27. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Unity approved it ultra fast (thanks to the Asset Store team!), so you can grab 2.2.0 now, with the physics integration. Free upgrade for anyone that's already got it.
     
  28. HeyJoeLang

    HeyJoeLang

    Joined:
    Jun 14, 2013
    Posts:
    4
    Hello,

    I purchased this asset with the intention of connecting one type of object at specific points to another. In order to achieve this, I need both objects to contain different Snap Joints ( Snap_A and Snap_B) that only connect to the other. I need a Snap Joint that works almost identical to the Self Matching Joint, but only connecting to it's counterpart.

    In order to achieve this, the ReadMe instructs the user to build off the Snap Joint Class:

    http://imgur.com/KNnJepy

    I derived the SnapJoint class with my own:

    Snap_A.cs:

    -------
    using SnapAndPlug;

    public class Snap_A : SnapJoint {

    public override string description
    {
    get
    {
    return "Connects to Snap_B only";
    }
    }

    public override bool CanConnectTo(SnapJoint other, SnapSocket movingPieceSocket, SnapSocket stationaryPieceSocket)
    {
    return other.GetType() == typeof(Snap_B);
    }
    }

    ------
    and Snap_B.cs:


    using SnapAndPlug;

    public class Snap_B : SnapJoint{

    public override string description
    {
    get
    {
    return "Connects to Snap_A only";
    }
    }

    public override bool CanConnectTo(SnapJoint other, SnapSocket movingPieceSocket, SnapSocket stationaryPieceSocket)
    {
    return other.GetType() == typeof(Snap_A);
    }
    }

    -------

    Clearly, I am making C# scripts here, as instructed to do from the ReadMe.

    The troubling part comes when the Snap Socket Component's Joint Type are incompatible with C# scripts, only accepting Joints. These scripts did not save as Joints:

    http://imgur.com/UIhmxd6

    Alternatively, I tried to create a Joint and use a custom script to run it.:

    http://imgur.com/g3qDpps

    But found out Joints run off of DLLs, not C# scripts:

    http://imgur.com/KMyTo4m

    Do I create DLLs, run the Joints off those, then attach those joints to my snappable objects?

    Did I miss a step in the the instructions on creating Joints and My Snap_A and Snap_B?

    I appreciate any and all guidance and advice.


    Thank you
     
  29. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Hi, @HeyJoeLang - thanks for that, I can see now that the instructions make a big assumption that I hadn't noticed before (I thought they covered everything already, but clearly not!).

    You did the right thing creating the scripts.

    Now - to work within Unity's core design - you have to create Unity Assets for each script. Unity does not allow gameobjects to refer to scripts - objects in the game can only refer to Assets. Fortunately, this is a two-click process!

    1. Click on the Assets menu
    2. First item is "Create ... "
    3. In that menu, usually at the top, is all the custom Assets that Unity has found in your project. This includes your custom SnapJoint classes. Click one to create it
    NB: you should NOT need to do anything special to enable this - simply by subclassing SnapJoint, your classes should automatically appear in that menu.

    NB2: when I've spoken to the betatesters (thanks, guys!) about how they're using SnP, very few of them have used the scriptable snapjoints. It seems I'm the main user, and I'm suspicious there may be bugs I haven't seen because I only use them in specific ways. If you have ANY problems with this, please contact me (email address in comments above or via website) and I'll look at them ASAP.
     
  30. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Feb 27th update: There's a bug in the current version on the Asset Store. I have a fix (tested with help from Richard GMX) and I'll get it uploaded ASAP.

    In the meantime, if you're using the latest version and having problems with snapping, message me / email me via support link on SnP website, and I'll send you a patched version of the DLLs that contains the fix.
     
  31. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    v2.2.1 is now submitted to Unity for approval ... anyone with 2.2.0 should get an auto email when they approve it, and I strongly recommend you upgrade!
     
  32. dworm

    dworm

    Joined:
    Jun 17, 2015
    Posts:
    74
    Hello I am having a problem in the CarBuilderScene.
    Once I move the car part near the socket it snaps to the right place but when I click it doesn't drop it and gives an error:

    NullReferenceException: Object reference not set to an instance of an object
    SnapAndPlug.SnapSocket.DisconnectWithoutMoving (Boolean recursingAlready)
    SnapAndPlug.SnapSocket.ConnectWithoutMoving (SnapAndPlug.SnapSocket otherSocket)
    SnapAndPlug.SnapSocket.SnapTo (SnapAndPlug.SnapSocket stationaryDoor, Boolean makeConnections)
    SnapAndPlug.SnappableSpawner.Update () (at Assets/Snap_fix/SnapAndPlug/Examples/PlayMode Example Scripts/SnappableSpawner.cs:311)

    Also I wanted to ask if you had in mind an easy way to save the object you create in runtime.
    Thank you.
     
  33. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    I'm sorry about this - there's a problem with the download currently on the Asset Store, it's giving out the old build. I'm going to try bumping a new version this week to see if it fixes it.

    If you have version 2.2.1 (Go to Window - Snapandplug - About) you should be OK, but if it says 2.2.0 you have the bugged version. If you email me (support address in plugin or on website or here) I'll send you the patched files.
     
  34. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    FYI - I've re-uploaded the files for all versions of Unity from 5.2.0 onwards. After Unity's reviewed it again, this should overwrite the broken copy on the Asset Store (probably a week from now).

    As above - if you find yourself with any version less than 2.2.1, email me directly and I'll send you the two changed files.
     
  35. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    You can do two types of saving.

    1. Save it like any other Unity gameobject (use any existing code from the Unity wiki, use any code from unity-developer blogs, use any asset-store asset). This will work fine: everything in SnapAndPlug was carefully created to work seamlessly with Unity.

    2. Use a script to save the "names" of the things that are connected, and which sockets they're connected by. This allows you to load the object later using DIFFERENT PIECES (if they have the same name). I think this is a rare use-case! But I'm experimenting with it on a project of my own.

    NB: option 2 took me about 5 minutes to implement a simple version for my own needs. I mostly used the built-in JSON serializers to do the hard work! If you want more info on that, I can dig through my code and try and write up an explanation.

    ...but I was using classes that might be Editor-only, so you might need to do more work to acheive this at runtime. I'd start with option 1 if that looks like it will work for you.
     
  36. dworm

    dworm

    Joined:
    Jun 17, 2015
    Posts:
    74
    Thank you, the patch worked perfectly! All is fine now.

    As for the saving part I was more inclined toward solution 2.
    Since I will work with prefabs mostly and only in runtime seems more handy to keep just a bunch of referenced prefab and their position.
    Also the option to be able to swap different parts is potentially awesome and something that might have been in my final goal too!
    So yeah if you can share some more info on this approach to give me a head start it would help, cheers.
     
  37. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    any update regarding Unity's Wheel Dynamics.... in the SAP docs it states...

    " Cars: If you stick a wheel at a funny angle, it will break the car-physics; this is a Unity bug. I spent a few months trying to find a workaround, but since Unity 5.2 nothing works any more. If you find a better solution, please share in the SaP forums or the support email address, and I'll upgrade this for the next version. "

    Any luck ??
     
  38. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    note: still wishing to test this on HTC VIVE
     
  39. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    @Banksy - Sorry, Unity didn't send me a notification for your reply (please email me directly - support@snapandplug.com - if you ever need a quick response).

    Wheel physics - it seems to be officially broken, known bug, at least as far as Unity 5.5 (I haven't tried with 5.6). For my projects, I'm now using custom physics calculations. There's some great wheel/vehicle-physics assets on the store too, mostly around $100-$200 - they replace Unity's vehicles, or add enough to it to make it useable.

    Vive - A few people contacted me to start testing VR builds. As before: if you email me I'll include you. I need people to try the demos, try integrating with their own projects. I've got a working FPS mode that seems to be a good base for VR apps, but it's already over 2,000 lines of new code. The final VR mode might have to be launched as an upgrade asset, it's a lot of work - but it's great fun to play with :).

    Here's some videos of the new in-game FPS mode:


     
  40. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    Built a test joint script based on manual as follows but does not show up the Assets/Create menu where all the other joints are available. I'm on Unity 5.6.0f3

    using UnityEngine;

    namespace SnapAndPlug
    {
    /**
    * You can subclass this and add your own custom logic for deciding whether a specific
    Joint is allowed
    * to connect to other joints
    *
    * c.f. the default provided implementations, e.g. UniversalJoint and SelfMatchingJoint
    */
    public class RoomJoint : SnapJoint
    {
    public override string description
    {
    get
    {
    return "Default joint: Only connects to itself";
    }
    }
    /**
    * Base implementation ignores the two pieces being connected, but
    * your custom implementations may need this data...
    */
    public override bool CanConnectTo(SnapJoint other, SnapSocket movingPieceSocket,
    SnapSocket stationaryPieceSocket)
    {
    return other.GetType() == GetType();
    }
    /**
    * Since v2.2.0:
    *
    * This callback is used to implement complex joints, e.g. the new Physics joints.
    *
    * In simple cases, you won't need it. But if you're making a joint-type that has
    to execute additional code every time a joint is connected or disconnected, use these two
    methods.
    */
    public override void DidConnectTo(SnapJoint other, SnapSocket movingPieceSocket,
    SnapSocket stationaryPieceSocket)
    {
    }
    /**
    * Since v2.2.0:
    *
    * This callback is used to implement complex joints, e.g. the new Physics joints.
    *
    * In simple cases, you won't need it. But if you're making a joint-type that has
    to execute additional code every time a joint is connected or disconnected, use these two
    methods.
    */
    public override void DidDisconnectFrom(SnapJoint other, SnapSocket
    movingPieceSocket, SnapSocket stationaryPieceSocket)
    {
    }
    }
    }
     
  41. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Hi, Robert.

    The way Unity works, you have to manually add a 1-liner to a class if you want it to appear in the menu (I can't do this automatically, I'm afraid). Docs here: https://docs.unity3d.com/ScriptReference/CreateAssetMenuAttribute.html

    TL;DR: put this above your "public class RoomJoint : SnapJoint" line:

    [CreateAssetMenuAttribute()]

    e.g.

    [CreateAssetMenuAttribute()]
    public class RoomJoint : SnapJoint
    NB: You might need to put a string in there as a parameter (this is the text that will appear in the menu) but off the top of my head it automatically uses the class's name
     
  42. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Also: I found some bugs in the custom-joints system recently, and there's multiple fixes coming in the next version. I've already got them in my local build, but I want to do some more testing before putting on the Asset Store.

    I also took the opportunity to add some new features to the custom joints.

    If you're using the custom joints right now, and want to use the latest build, email me and I'll send you a temporary version with the fixes. If you hit any problems, you can always roll back to the live one on Asset Store.
     
  43. RobertMassart

    RobertMassart

    Joined:
    Apr 26, 2014
    Posts:
    16
    Yes I would diffently take any new fixes or builds
    I'm working on a snap dungeon but joints need to do spatial checks so rooms don't crash into each other so I need to override the can connect
     
  44. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Right, but email me. support @ snapandplug.com
     
  45. marklee

    marklee

    Joined:
    May 5, 2015
    Posts:
    2
    Can this work with Hololens?
     
  46. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    @marklee - it uses 100% Unity standard code, so I would expect so. What might make it work / not work?
     
  47. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    120
    is it possible to set this up with some code to pick and snap together parts randomly without player interaction?
    I want my game to have random levels but I want it to be off grid and I thought, if this could be made random and automatic, then it could be my level generator.
     
  48. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Yes - that's what I originally created it for :).

    Random generator code is only a few lines, something like:

    foreach( var socket in group.GetUnconnectedSockets() )
    socket.SnapTo( GetRandomPiece().GetRandomUnconnectedSocket() );​

    where "GetRandomPiece()" is your own method that picks a random prefab and instantiates it, and the other methods are all part of the SnapAndPlug API already.

    NB: "socket.SnapTo" automatically adds the new piece to the group, so you don't even have to keep track of what's added / not-added yet.

    (although in practice you probably want to pass the socket's SnapJoint to your GetRandomPiece() method, so that you only return random pieces that are compatible with the starting socket)

    NB2: I personally would write a lot more than 3 lines of code to do this in a game, because I'd want more intelligence in the level-design, and more tweakable features, etc - but you can get started very quickly, and then build on that.
     
  49. Nevercallmebyname

    Nevercallmebyname

    Joined:
    Nov 18, 2013
    Posts:
    120
    wow. I was expecting that to be completely impossible but there it is.
    and yeah I'd also do it with several lines to get the generation just right and then end with a line that basically says when all pieces are in use at least once use an end cap instead. I mean I don't want the level going on forever.
     
  50. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    THREE ANNOUNCEMENTS FOR 2018:

    1. SnapAndPlug is now 30% off in the Xmas sale (grab it now!) - https://www.assetstore.unity3d.com/#!/content/21930

    2. MAJOR update coming over Xmas/January: new demos, new VR features, in-game construction kits, etc.

    3. If you want cutting-edge access, you can subscribe to my patreon to get this and my other assets with live updates every month, and request your own features/additions (cheaper than buying the asset, but breaks even over the course of a year or so). https://patreon.com/tmachine