Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Mount Points

Discussion in 'Assets and Asset Store' started by Tryz, Mar 22, 2014.

  1. MrAdventure

    MrAdventure

    Joined:
    Aug 22, 2012
    Posts:
    28
    Hi Tim,

    Thanks for the reply, and sorry for being late getting back to you.

    I reset up my project to use Mount Points, so here's what I've got for issue #1.

    Both my Plant and Fruit are instantiated. In the first image, you can see my folder structure, with Plants having the prefabs for the parents, and Fruit for the children. On the right is my Hierarchy. The Seeds class is used to instantiate Plant where the user clicks, then Plant instantiates Fruit after a given time. The first picture is not in Play mode, and no Plants or Seeds exist in the Scene at this point.


    Prefabs.JPG

    Runtime.JPG

    In the second (above) image are two different shots of the Hierarchy during Play mode. In the first, the Plant has been instantiated, in the second, it has instantiated the Fruit, and deleted itself. I also tested it with manually making the Fruit the child of the Plant (which is my usual method,) and they were both destroyed correctly after a time, but with the following error message happening in both cases (when I parent the fruit to the plant, and when I don't.)

    Error.JPG

    To use Mount Points to instantiate the fruit, this time, I used:

    Code (CSharp):
    1. GameObject newFruit = MountPoints.InstantiateAndConnectPoints(plantModel, "MountPoint0", "Plants/Fruit/Eggplant Fruit", "MountPoint0");
    Thanks for the help, I have to pursue issue 2 later.

    Victor
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Hey @MrAdventure ,

    I updated the source code from the sample I put together to include deleting the fruit and tree after they grow. Everything seems to being working well. That's what you'll see below. How does this source code compare to yours?

    Issue #1 occurs when a prefab is being modified as opposed to an instance. I'm wondering if you're referencing a transform that is really part of the prefab vs. the instance. I see your eggplant clone in the hierarchy, but it would be good to see your code.

    Issue #2 is occurring because the scale is set to 0 at some point. Since I use 1 / scale... 1 / 0 is invalid... and you get the error. The quick fix is to just make sure you don't let a scale go to 0 (or too close to 0). I'll get some code to try to prevent it on my end too.

    Is your project small enough that you can email it to tim@ootii.com? My little sample code below shows everything you want to do should work. So, I'm wondering if you took a different approach to coding it than I did. If you can send the project, that would help. If you can't, maybe the code below will help you.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using com.ootii.Entities;
    4.  
    5. public class GrowCode : MonoBehaviour
    6. {
    7.     public GameObject Tree = null;
    8.  
    9.     public string FruitPrefab = "Fruit";
    10.  
    11.     public float TreeGrowTime = 3f;
    12.  
    13.     public float TreeBloomTime = 2f;
    14.  
    15.     public float TreeLiveTime = 2f;
    16.  
    17.     public float FruitGrowTime = 3f;
    18.  
    19.     public float FruitLiveTime = 2f;
    20.  
    21.     public float FruitMaxSize = 0.25f;
    22.  
    23.     private bool mTreeGrowing = false;
    24.  
    25.     private bool mTreeMature = false;
    26.  
    27.     private bool mFruitGrowing = false;
    28.  
    29.     private bool mFruitMature = false;
    30.  
    31.     private float mElapsedTreeGrowTime = 0f;
    32.  
    33.     private float mElapsedTreeLiveTime = 0f;
    34.  
    35.     private float mElapsedFruitGrowTime = 0f;
    36.  
    37.     private float mElapsedFruitLiveTime = 0f;
    38.  
    39.     private GameObject Fruit = null;
    40.  
    41.     // Use this for initialization
    42.     void Start ()
    43.     {
    44.  
    45.     }
    46.  
    47.     // Update is called once per frame
    48.     void Update()
    49.     {
    50.         if (Tree == null) { return; };
    51.  
    52.         if (mTreeGrowing && mElapsedTreeGrowTime < TreeGrowTime)
    53.         {
    54.             mElapsedTreeGrowTime += Time.deltaTime;
    55.  
    56.             // Grow the tree
    57.             float lScale = mElapsedTreeGrowTime / FruitGrowTime;
    58.             if (lScale > 0f)
    59.             {
    60.                 Tree.transform.localScale = new Vector3(lScale, lScale, lScale);
    61.             }
    62.  
    63.             // Instanciate the fruit
    64.             if (Fruit == null && mElapsedTreeGrowTime >= TreeBloomTime)
    65.             {
    66.                 Fruit = MountPoints.InstantiateAndConnectPoints(Tree, "Branch 1", "Prefabs/Fruit", "Branch 1");
    67.  
    68.                 mFruitGrowing = true;
    69.                 mElapsedFruitGrowTime = 0f;
    70.             }
    71.         }
    72.  
    73.         // Grow the fruit
    74.         if (Fruit != null && mFruitGrowing && mElapsedFruitGrowTime < FruitGrowTime)
    75.         {
    76.             mElapsedFruitGrowTime += Time.deltaTime;
    77.  
    78.             // Grow the fruit
    79.             float lScale = mElapsedFruitGrowTime / FruitGrowTime;
    80.             if (lScale > 0f)
    81.             {
    82.                 lScale *= FruitMaxSize;
    83.                 Fruit.transform.localScale = new Vector3(lScale, lScale, lScale);
    84.  
    85.                 mFruitMature = true;
    86.                 mElapsedFruitLiveTime = 0f;
    87.             }
    88.         }
    89.  
    90.         // Destroy the fruit after some time
    91.         if (Fruit != null && mFruitMature && mElapsedFruitLiveTime < FruitLiveTime)
    92.         {
    93.             mElapsedFruitLiveTime += Time.deltaTime;
    94.             if (mElapsedFruitLiveTime >= FruitLiveTime)
    95.             {
    96.                 GameObject.DestroyImmediate(Fruit);
    97.                 Fruit = null;
    98.  
    99.                 mTreeMature = true;
    100.                 mElapsedTreeLiveTime = 0f;
    101.             }
    102.         }
    103.  
    104.         // Destroy the tree after some time
    105.         if (Tree != null && mTreeMature && mElapsedTreeLiveTime < TreeLiveTime)
    106.         {
    107.             mElapsedTreeLiveTime += Time.deltaTime;
    108.             if (mElapsedTreeLiveTime >= TreeLiveTime)
    109.             {
    110.                 GameObject.DestroyImmediate(Tree);
    111.                 Tree = null;
    112.             }
    113.         }
    114.     }
    115.  
    116.     /// <summary>
    117.     /// Place the buttons and send messages when clicked
    118.     /// </summary>
    119.     void OnGUI()
    120.     {
    121.         if (GUILayout.Button("Grow"))
    122.         {
    123.             if (Fruit != null)
    124.             {
    125.                 GameObject.DestroyImmediate(Fruit);
    126.                 Fruit = null;
    127.             }
    128.  
    129.             mTreeGrowing = true;
    130.             mTreeMature = false;
    131.             mElapsedTreeGrowTime = 0f;
    132.  
    133.             mFruitGrowing = false;
    134.             mFruitMature = false;
    135.             mElapsedFruitGrowTime = 0f;
    136.         }
    137.     }
    138. }
    139.  
     
    Last edited: Apr 18, 2015
  3. MrAdventure

    MrAdventure

    Joined:
    Aug 22, 2012
    Posts:
    28
    Thanks again Tim,

    I'm sharing a Dropbox link with you via email for the instantiation issue.

    As for the scale, you're right, it was going to less than 0 before being destroyed, so that part is now fixed. I finally caught it thanks to the Monitor Components asset, which I highly recommend.

    Victor
     
  4. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    I just shot you an email.

    You were accidentally passing the prefab into the MP functions instead of the instance you created from the prefab.

    I tested it out and everything worked with no errors. Cool project BTW. :)
     
    Last edited: Apr 22, 2015
  5. MrAdventure

    MrAdventure

    Joined:
    Aug 22, 2012
    Posts:
    28
    Thanks Tim, you're super helpful! And thanks for the kind words. :)

    I'm looking forward to trying out mount points with my avatars. I have a wheelbarrow animation that I got from Mixamo, which has been at the back of my mind.

    Take care,

    Victor
     
    Tryz likes this.
  6. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    444
    Can I play animations on the attached mount through string?

    Like..

    MountPoints.PlayAnimation("WeaponMount", "ExtendSword");?
     
  7. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Hey Gekigengar,

    Mount Points connects GameObjects together. So, you can do anything to a connected object that you can normally do with a GameObject...including playing animations.

    There isn't anything special in Mount Points like what your example shows. You'd just use what ever you'd normally use to play the animation.

    I hope that makes sense.
     
  8. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    444
    Ah, I thought it might be easier if the function is available.

    I need an easy way to play everything attached to an attachment/mount point, a single animation with the same name.

    Thanks anyways!
     
  9. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    400
    Hey @Tryz I'm setting up MP in a new project using Unity 5.0.2f1 and the latest version of MP, and I ran across something maybe not working right (or I'm just doing something wrong!)

    I have my "Player" gameobject, which has no special components and one child.
    This child is my "Model" gameobject that has the MP component, and a script that loads in the parts and attaches them to the mountpoints. This gameobject has the rig root as a child. (see image for hierarchy screenshot)

    At startup I want to add on the body parts with InstantiateAndConnectPoints, all works as it should! No issues there.
    However, my character is too big (because I exported everything too big, whoops!), so I want to scale my top level "Player" gameobject down a bit in edit mode but no matter what I put the values at the body part gameobjects always spawn in at 1,1,1 scale.

    I guess this is because the mountpoints have the "Ignore Parent Scale" property box checked, but it wont let me uncheck it!

    I can just set the "Player" scale in code after all the instantiation is done, which works well enough for now, but if I want to add anything more to the player later (swords!) they Instantiate in at a huge size.

    Any idea!?
    Thanks again!
     

    Attached Files:

  10. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Hey DMeville,

    You're right. I left some debugging code in and it prevents the checkbox from working. While testing, I also noticed that I had another issue when it came to preserving the scale. I've fixed that too.

    If you'd send me an email, I can shoot you the latest build before I send it to Unity. I just want to make sure it solves your issue. Send it to tim@ootii.com :)

    One last thing to mention... I don't manage the scale of the objects at run-time, only edit time. The reason is that I'd have to have every mount point run an Update() test every frame and that seemed expensive when most objects in most games don't scale. If you wanted to preserve the scale for a scaling parent at run-time, you can add the Update logic for the specific objects you scale and I can help with that.

    I hope that last part makes sense.
     
    DMeville likes this.
  11. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    400
    @Tryz It seems like it's working perfect now. Thanks again!
     
  12. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Awesome. New package was just submitted to Unity. Should be available for everyone in the next couple of hours.
     
  13. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,060
    @ Tryz,

    Thinking of buying this. I can see how easy it would be when attaching helms, swords etc. What about armour and clothing pieces though? There are all the issus with sizing and scale etc when attaching. Does Mount Points help with this? Could the webdemo accomodate this? What kind of armour/clothing works best when using this asset?
     
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    You've really got two types of objects: static meshes and skeletal meshes.

    Hard objects (swords, shields, plate mail breast plates, etc) all work the same. You assign mount points and connect them. The scaling happens automatically (if you allow it).

    Flexible objects (shirts, pants, chainmail jerkin) are done with skeletons so they have the same bones as your character. This is what allows them to scale and animate when you attach them. This is what the pants and shirt are in the demo.

    You do have to build flexible objects like you'd build any other skeletal mesh... with bones. Then, they import like any other "character". I've included a "Custom Content" document in the asset and go through the steps of building shorts using Fuse + Marvelous Designer + Maya + Unity.

    There's not really a "what works best". It's a matter of determining if the object you want to attach is hard or flexible and taking that approach. MP supports both. :)
     
  15. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,060
    @ Tryz,

    Understood, I think. Thanks for the quick response
     
  16. JeBuSBrian

    JeBuSBrian

    Joined:
    Mar 3, 2013
    Posts:
    14
    Asset Store gives me a warning about possible incompatibilities with Unity 5. Anything to worry about?
     
  17. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Hey JeBuSBrian,

    It is U5 compatible. Not sure why Unity is giving a warning.

    I've tested all my assets with 5. You won't have any issues.
     
  18. JeBuSBrian

    JeBuSBrian

    Joined:
    Mar 3, 2013
    Posts:
    14
    Thanks. Feel free to ignore my email. I sent it before remembering the forum.
     
  19. Thoreandon

    Thoreandon

    Joined:
    Aug 21, 2014
    Posts:
    37
    Interessting Product, i have a lot of Weapons and a lot of Chars to connect them.
    Is there an easy way to align Mountpoints to 'complicated' Objects?
    I looked at your video and it looked very easy, becouse the pivot of the weapon was just turned 270 degress.
    But what, if the pivot is on some stupid place and its a two handed weapon where left and right Hand have be aligned?
    Can i edit a mountpoint at runtime in scene view to align it properly when it is connected?
    I mean, when the animation is playing and i see some problems, it would be easier to align directly in the animation. Going back to T-Pose and align there is a Pain.
    I know i can change animation in Edit Mode but thats more steps again.
     
    Last edited: Aug 8, 2015
  20. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Hey @Thoreandon ,

    Great questions. Mount Points is a "parenting" solution, not an "IK" solution. That's an important distinction.

    Let's say you have a typical machine gun where the the right hand would be on the handle/trigger area and the left hand on the barrel...

    The mount point on the handle would connect the gun to the person's right hand at any rotation and any offset you need to make the gun a child of the person's hand. So, as the hand moves with animations, the gun will as well. it will be locked to it because the gun actually becomes a child of the hand's transform.

    Here's where the difference between parenting and IK comes in. The mount point on the barrel will not pull the person's left hand to it. It won't determine bones in the arm and hand and twist/swing them to create a connection. For that, you need something like Bone Controller.

    In fact, because Mount Points uses Unity's parent-child hierarchy at it's base... objects cannot be parented to two different mount points at the same time. (Which makes sense in most situations.)

    As for aligning while animations are playing:

    1. Remember we're parenting transforms to transforms. So the gun will stay connected to the bone (transform) that you assign it to... even as it animates.

    2. Unity doesn't keep changes that are done at run-time. Unfortunately, this is a Unity issue. So, if you run your game and then tweak positions... when you stop using playing, Unity will undo the changes. You'd have to write down the rotation tweaks and reapply them.

    The reply is a little long, but I wanted to be thorough :)
     
  21. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,060
    @Tryz,
    Could you make some Playmaker actions/support for it?
     
  22. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Unfortunately, I'm not sure when I'll get to it. I now own Playmaker, but haven't looked into it. :(
     
  23. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,060
    No worries. . But would knit well with this Asset.... ;)
     
    Tryz likes this.
  24. Thoreandon

    Thoreandon

    Joined:
    Aug 21, 2014
    Posts:
    37
    I am aware of what you wrote becouse i already wrote my own system for connecting (without IK) and i have an editor where i can play an animation frame by frame (in Edit Mode) and align the weapon there and save the position.
    So its possible to be precise. Of course, its not perfect but its good enough for what i need.

    The Problem is that i have to do this for each weapon and for each character, which is too much work to do when you have 6-8 Chars and 30-40 Weapons and lots of Animations.
    You Software seems to be a good solution but if i put mount points and then see in the animation (in Edit Mode) that i have to tweak it, how can i do it?
    When i understand correctly, MP does lock the weapon, so its not editable. Can i unlock and move the MPs?
    Another solution would be maybe, instead using T-Pose, using the end Point of an Animation and attach it there.
    Or, perhaps i better have a look at IK. Havent done it yet.
     
    Last edited: Aug 9, 2015
  25. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    I don't think that would be an issue at all.

    You can use the arrow handles to move and rotate mount points while in edit mode. Since they are parented to the bones (ie the hand bone), it doesn't matter if you're in the middle of an animation or not.


    At 1:07 of the video, you can see me pointing out the move handle of a mount point that is attached to the right hand bone. It wouldn't matter if the character was in mid-animation or not. You'd just move and rotate the mount point until you get it how you want it.

    Then, for each gun, you'd add a mount point to the handle so that it aligns with the same forward and up direction. Then, you'd just connect them in code. At 2:51 in the video, you see two mount points (one for the hand and one for the weapon) coming together.

    With MP, you'd have to setup a mount point on each character and then a mount point on each weapon. In your case, that's 8 + 40 (not 8 x 40). The number of animations won't matter since the "hand bone" is the "hand bone" regardless of the animation.

    I hope that makes sense. :)
     
  26. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Just bought Mount Points which I am excited to use in my project, however the Mount Points script seems to have changed in the latest version in the Asset Store, and the steps to add Mount points seems to have changed to whats in the manual? when I look at the Sample scene each Mount Point now has long GUID numbers and a Name and M Name fields, all these fields are blank when I add the Mount Points to a new parent object, and when I set the Point size to 1 or more, I just get blank entries and no actual Mount Points to set on my object?

    Am I missing something obvious?
     
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Hey @Greg Bassett ,

    Once I get home, I'll check it out. That doesn't sound right and I haven't had it reported before, but I'll go through the documentation and the demos again. I'll report back ASAP.
     
  28. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Ok thanks Tim, look forward to your report!
     
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Well, I'm not seeing anything odd here.

    I created a new Unity 5.1.1 project, downloaded and imported MP, and opened the Sample scene. With the exception of the man, everything looked the same as the documentation and as I'd expect. I created some mount points, attached objects, etc. All was good.

    Can you email me a screenshot of what you're seeing? Send it to tim@ootii.com. That might help me figure out what's going on.

    Are there any other assets in your project right now? I'm wondering if the issue has to do with rendering the inspectors...
     
  30. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Here is a shot of the inspector for the DefaultAvatar in the Sample scene. I am using some other assets in my project, so I will try a completely new project and only import Mount Points.

    mp1.png

    Thanks for super fast support on here, much appreciated!
     
  31. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Just to let you know, it works fine in completely new project... the only other asset I have in my existing project is Easy Touch 4.

    I will try importing ET4 into my new project and see if it breaks MP's, will keep you posted!
     
  32. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Hi Tim, I can confirm MP's working perfectly fine with Easy Touch 4 now both imported freshly into a new project in Unity 5.1.0f3.

    It's a shame I couldn't just import MP's without any issue into my existing project, however I can simply setup this new project with my existing scripts etc. pretty quickly, so its not the end of the world!

    I will post a YouTube of my project in action once I get Mount Points setup with my runtime touch positioning code... :)
     
  33. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    That's weird.

    From your images, Unity isn't using the custom Mount Point inspector. That's why you're seeing all the raw fields that I normally hide.

    I can't think of any reason it wouldn't render. I don't own ET4, but I'll poke around the forums. Maybe we have a conflict with each other.

    Sorry for the hurdle, but I'm glad you're able to move forward. I'd love to see the video when you get it up!
     
    Greg-Bassett likes this.
  34. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    OK, I am all up and running, quick question, is there anyway to increase the magnet area? e.g the radius of the detection area around each Mount Point? hope that makes sense, I cannot see anything obvious in the Inspector for each Mount Point... Thanks in advance!
     
  35. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Unfortunately, I didn't think about exposing that in the inspector. I'll put it on my board.

    If you open the MounPointsEditor.cs file, at line 13 you'll see "mSnapDistance". Just change that and you'll be good.
     
    Greg-Bassett likes this.
  36. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,108
    I think I'd like to have the snap distance exposed too. I was just thinking about that yesterday. :)
     
    Last edited: Sep 10, 2015
    Tryz likes this.
  37. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Ok, thanks! BTW I think I found the answer to my problem yesterday, it appears the Editor scripts had not compiled properly after import, I deleted one of my scripts accidentally in my original project, then added it back from backup, and then it forced some scripts to recompile and then I noticed the Mount Point script in the Inspector showed up as it should. :)
     
    Tryz likes this.
  38. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,108
    BTW, I just started a review of Mount Points before attempting to integrate it with a test project, and I was wondering if there was any special advice on setting up items so they can be mounted to both left and right hand? Like, if in the game there are guns, grenades, knives, etc. that are available in the environment ... on tables, on the floor, and so forth ... and the players and NPCs can pick them up with either hand.

    I was thinking I'd simply orient the objects for right hand pick-up and have the left hand compensate. But I'm refreshing myself on the docs now, and thought I'd see if there are any pointers or gotchas.

    I suppose I could also have two mount points on each item, one for left mount and one for right mount.
     
  39. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    I can't think of any special gotchas.

    In something like a sword or pistol, it would just be the one MP on the weapon and then an MP in each hand.

    If you do have a weapon that would change orientation or position, usually the hand MP would do that. However, I could image there being times when you'd need multiple MPs per hand to reflect different orientations. I think this would just be trial and error.
     
    hopeful likes this.
  40. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Me again... I am able to Mount Points in code with no problems, however I am unable to Disconnect them via code.

    You haven't got DisconnectPoints in your SampleUI script...

    I have tried, the Debug.Log outputs the number of mount points I have on the patentObject correctly, however the points do not disconnect?

    Code (csharp):
    1. MountPoints lParentMPList = parentObject.GetComponent<MountPoints>();
    2. Debug.Log (lParentMPList.Points.Count);
    3. MountPoints.DisconnectPoints(lParentMPList.Points[0]);
    4. MountPoints.DisconnectPoints(lParentMPList.Points[1]);
    Thanks in advance!
     
  41. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Hey Greg,

    I'm thinking that in your example, "lParentMPList" is the parent point. In the example of a "hand" MP with a "sword" MP as a child, you want to use the child in the DisconnectPoints() function.

    Here's a couple of examples I just tried that worked:
    Code (CSharp):
    1.             GameObject lSword = GameObject.Find("Sword");
    2.             MountPoints lMountPoints = lSword.GetComponent<MountPoints>();
    3.             MountPoint lSwordMP = lMountPoints.GetPointFromName("Handle");
    4.  
    5.             //lSwordMP.ChildTo(null);
    6.             //MountPoints.DisconnectPoints(lSwordMP);
    7.             MountPoints.DisconnectPoints(lMountPoints.Points[0]);
    8.  
    Any of the bottom three versions work. Just remember that you pass in the child to disconnect it. I don't have a parent version so there is no confusion in the situation that a MP is a child and a parent.

    Give that a try and see if that helps.
     
  42. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Question, is it possible to snap a GameObject into place, but not parent it to the GameObject it connects too? I just want to use the Mount Point positions to place my GameObjects next to each other, but not connect them together in the hierarchy?
     
  43. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Not without a small code modification...

    All the connecting work is done in the mount point's "ChildTo" function. That last line is what does the parenting. If you comment it out, you should get what you want.
     
    Greg-Bassett likes this.
  44. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Thanks! :)
     
  45. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Which lines should I comment out? I have commented out line 282 of MountPoint.cs, but I am still getting some parenting?

    Code removed for privacy reasons, apologies Tim!
     
    Last edited: Sep 11, 2015
  46. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    It should be that last line...
    rParent.AddChild()

    I haven't tried it, but that should be the right place.
     
    Last edited: Sep 11, 2015
  47. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Thats the line I commented out first, but it did not stop the parenting...? will make sure any code snippets I share in future are via email only... thanks again for your super re-active product support! Outstanding!!!! :)
     
  48. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,255
    Thanks for the clean up.

    Ah... missed it.

    Comment out line 282 as well:
    Owner.transform.parent = rParent.Anchor.....

    I just tried it and that worked.

    Not a problem. I'm happy to help. :D
     
  49. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Perfect, that works a treat! Have a good weekend! :)
     
    Tryz likes this.
  50. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    618
    Hi Tryz,

    Here is a video of my app in action, using your Mount Points asset at runtime! :)

    Thanks for all your previous help!

     
    Tryz and hopeful like this.
unityunity