Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mount Points

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

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402

    Get it at the Unity Asset Store.

    Raise the bar with run-time swappable clothing and gear!

    With Mount Points 2.0, you can swap out our character's clothing and equipment at run-time. Use the "Skinned Items" list to preview clothing in the editor and then have your character appear with it in game.

    Mount Points 2.0 also includes an advanced skin masking system that allows you to hide the the character's body that's under the clothes. No more bleed through.



    With Mount Points, you can simply drag two objects together and when their mount points get close, they snap together like magnets. Drag the objects away from each other and they come apart. Mount Points manages the relationship, orientation, and scale for you. Mount Points doesn't try to recreate Unity’s hierarchy, it leverages and simplifies it.

    Use Mount Points with characters from Morph3D, Mixamo, UMA, and everyone else...

    Features
    Mount Points supports the following features:

    • Simplified object connections
    • Use with any GameObject
    • Preserves child scale
    • Precise position snapping
    • Precise orientation snapping
    • Mount points attach to bones for animating
    • Supports skinned meshes
    • Supports masks to reduce penetration
    • Easy access through editor or code
    • Easy access through PlayMaker
    • Code, so you can modify as needed

    For more details, see the User Guide and the Content Creation Guide.


    This thread is for ideas and issues.
     
    Last edited: Nov 20, 2017
    Flurgle likes this.
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
  3. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Bookmarked. Thanks.
     
  4. negativecap

    negativecap

    Joined:
    Jan 27, 2013
    Posts:
    99
    Does mountable through code mean that I can stop messing around with enabling and disabling mesh renderers for weapons and such? Just pop an object from the world into the player or ai hierarchy in game and take off, huh? Sounds like a better way to do it to me. Thanks.
     
  5. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi ZJP.


    Hey negativecap! Yes, exactly.

    I read somewhere that it was suggested you take all 10 swords/guns/etc, attach them to your player, and then enable and disable the meshes as you need. That just seemed so crazy to me.

    What you said is exactly right. Given your character (with mount points setup) and a sword (with mount points setup), you can create and connect at run-time. Just use a line of code like this:

    InstantiateAndConnectPoints(AvatarGameObject, "LeftHandPoint", "Swords\SwordPrefab1", "HiltPoint");

    There is a little setup at first since you have to create the mount points for objects you want to do this with, but it literally takes me 15 seconds to put a mount point on a new sword and save the prefab.


    Side note...
    For anyone that doesn't know, if you buy the Motion Controller before EOD Friday 3/28... I'll send you this for free. Otherwise, it should be on the Asset Store late next week.
     
  6. Goldrake

    Goldrake

    Joined:
    Feb 6, 2010
    Posts:
    148
    Simply fantastic!
     
  7. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Took longer than expected, but Mount Points is released!
    https://www.assetstore.unity3d.com/#/content/16318


    I've gotten great responses from pre-release users. My favorite from Matt:
    "I had written plenty of custom tools to do this very thing but none were as modular or effective as this one."


    If you choose to get it, please let me know what you think. I really do want to create tools people find useful.


    On the flip side, if you have an issue, don't hesitate to email tim@ootii.com. As you can tell from my other products, I really do care about customer support. :D
     
  8. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    I have questions depending on your new mount points asset.
    Can i made a mount point in his hand and then as an example let him grab a rope and that rope can then lift him up or swing him around?
    Can i use this only on my player or can i let different characters have mount points and let them grab each other?
    Can that work with ragdolls and/or animations?

    I think of using this to make some things look more dinamic.
     
  9. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi RandAIThor,

    The answer to all of these is 'yes', but obviously you'll have some implementation work to make the scene happen as you described.

    What I mean is that Mount Points uses Unity's hierarchy to parent objects together. So in your question about animations... when a sword is attached to a hand and the hand is animated, the sword moves. That's exactly what you see in my demo.

    In the case of the rope, the hand mount point would be the child of the rope's mount point. Then, the hand (and theoretically the character it belongs to) would move. I haven't tried this. The only thing I could think that would be an issue is if the skeleton truly follows the hand. You might have work to do there, but that would be outside of Mount Point's control.

    Hope that helps,
    Tim
     
  10. -Singularity-

    -Singularity-

    Joined:
    Jul 27, 2014
    Posts:
    122
    Hi Tim,

    This looks interesting.

    How well do you feel this would lend itself to snapping together other instantiated prefabs at runtime? For example wall panels, foundation blocks etc that have been designed to fit together but would need to be placed precisely.

    Would it be possible to assign a specific vertex on a model as a mount point?

    Is there a limit to the number of mount points on an object?

    Would it be easy enough to make sure certain objects cannot connect to others? For example; a Ceiling might snap connect to a wall, and a wall to a floor, but a ceiling would not connect to a floor.

    Appreciate this is probably moving away from your intended use case but any thoughts would be great.

    Thanks,
     
  11. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,929
    I would like to know this too!

    Also, could use use this asset to make mount points from the character to a chair or wagon seat or a character to a horse? Looks like a very useful asset!
     
  12. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hi Singularity and Teila,

    No limit to the number of mount points and you can nest them as deep as you need to. Although things could get buried. :)

    What you described (wall panels, blocks, etc.) makes total sense and is doable now (in edit mode). Unfortunately, I only have drag-and-snap code at edit time. That said, I don't think it would be difficult to have it be for run-time as well.

    You can do snapping through code at run time (as I show in the demo), but that would mean you'd have to clone the current drag feature and then call the snap code. The biggest challenge I'd have with this is supporting a generic drag feature (ie handles like the Unity editor has) that would work with everyone's unique games.

    Current there are no exclusion lists. That's definitely an interesting idea. It wouldn't be too hard to have it based on name or tag.

    As far as having a mount point tied to a vertex, that's tricky. You can tie it to any position you want based off the root position or a specific bone (if you have them). In fact, you could create a mount point that looks like it's floating in air. So, in that sense you could place it where ever you want. However, if you're taking about tracking a vertex as it moves (ie a skinned mesh), I don't believe that's possible since most of the skinning work is done on the GPU.

    Lots of interesting ideas and I don't think they would be too difficult to do. I'll add these things to the 'to-do' list, but I'm not sure when I'll get to them. Priority is based on my time and people's interest. +2 to interest from the both of you :)
     
  13. -Singularity-

    -Singularity-

    Joined:
    Jul 27, 2014
    Posts:
    122
    Thanks for the quick response Tim, I'll definitely be following this.

    It's should be a purchase for me anyway given how elegant a solution it presents for its intended purpose!

    Cheers
     
  14. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,929
    Thanks! Glad you are considering our ideas. :) Looks like a great asset.
     
  15. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Is there any support for two-handed weapons? I'm thinking stuff like rifles, two-handed swords, staffs, etc.
     
  16. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey Steve,

    There isn't anything that would automatically force the second arm bone to bend.

    What you would do is put the mount point on the primary hand and then attach the two-handed sword to it. Then, you'd use standard animations to bend the secondary arm bones towards the hilt. It would look like it's being held by two hands, but it's really only using the mount point in one.

    (That said, I am working on a skeleton and bone solution now and that's an interesting case to solve for. :) )

    Thanks,
    Tim
     
  17. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    For the secondary hand, I guess the idea is to use, say, a left hand IK target to a child Transform of the weapon at a secondary location? I'm a noob when it comes to character animation and haven't even gotten IK to work properly yet, so if you were to include an example of such a thing in a future update, that'd be a pretty appealing feature.
     
  18. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    You could do it a couple of ways.

    1. Exactly. If you're using Unity Pro, Final IK, or another IK solution you'd use the IK target to pull the left hand to the weapon.

    2. Animations. In this case, you'd use an animation tool like Maya, Motion Builder, or Blender to create an animation that has the left hand where you want it. This is especially true if you've got a sword swing animation or something.

    I'll put the example on my list of to-dos. Seems like a useful thing to show.
     
  19. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Thanks for the very helpful reply!
     
  20. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    just purchased :) Hope to incorporate into my game to snap lego style blocks together.

    Running Unity Pro
     
    Last edited: Oct 17, 2014
  21. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Cool. Feel free to email me at tim@ootii.com if you need help. :)
     
  22. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Picked this up while it was on sale, great asset! Works great for rigid equipment (swords, helmets, etc)

    Looking at the included scene and the sample code it only shows connecting these objects. I've taken a look at the UserGuide and although I haven't tested this yet, it looks like you can detach points with the DisconnectPoints() function. Is this the correct way to do this?

    What about skinned meshes? After connecting them with MountPoints.InstanciateSkinnedMesh(parent, prefab), is there a way to disconnect them and remove the connected part? If not I think that would be the last feature needed to make this a perfect asset :)

    EDIT: After further testing I've noticed the functions return gameobjects, and I can "remove" the connection by storing that gameobject, and calling DestroyImmediate(gameObject).

    However, I did notice sometimes my MountPoints.InstantiateAndConnectPoints call fails and throws this error:

    Code (CSharp):
    1. NullReferenceException
    2. com.ootii.Entities.MountPoint.ChildTo (com.ootii.Entities.MountPoint rParent) (at Assets/ootiiMountPoints/Scripts/ootii/MountPoints/Entities/MountPoints/MountPoint.cs:282)
    3. com.ootii.Entities.MountPoints.ConnectPoints (com.ootii.Entities.MountPoint rParentPoint, com.ootii.Entities.MountPoint rChildPoint) (at Assets/ootiiMountPoints/Scripts/ootii/MountPoints/Entities/MountPoints/MountPoints.cs:98)
    4. com.ootii.Entities.MountPoints.InstantiateAndConnectPoints (UnityEngine.GameObject rParentObject, System.String rParentPoint, System.String rChildPrefab, System.String rChildPoint) (at Assets/ootiiMountPoints/Scripts/ootii/MountPoints/Entities/MountPoints/MountPoints.cs:306)
    5. ToggleBodyparts.Update () (at Assets/ToggleBodyparts.cs:38)
    6.  
    I've found selecting the prefab that doesn't connect, unlocking it and locking it again fixes the problem ... until the error randomly happens again. I haven't figured out what exactly is causing this to happen. Any idea?

    Additionally I've found that creating prefabs in the resources folder with mountpoints creates a new "MP_New Mount Point" in the scene (parented to nothing) With lots of mount points I can see this becoming cluttered. Anything I can do about that?

    Thanks, keep up the great work!
     
    Last edited: Oct 28, 2014
  23. Tryz

    Tryz

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

    Thanks for the comments.

    Hah, you updated before I could respond. :)

    Exactly right with simply destroying the GameObject. I figured people would probably have an inventory system with different clothing objects. By giving you the GameObject, I figured you could hide it, destroy it, etc. as you saw fit.

    For both the issues you wrote about, I looked at the code and nothing is jumping out at me. Give me a day and I'll look into them. Hopefully I can get them cleaned up quickly.

    Thanks again!
     
    Last edited: Oct 29, 2014
  24. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Alright, thanks! Let me know if you come up with anything - I'll take a deeper look into the demo scene and give the user guide a more thorough read. Thanks!
     
  25. Tryz

    Tryz

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

    I've got a partial answer for you...

    On the second issue. The way I was able to duplicate this was by putting an object in the scene, adding mount points, and then creating a prefab out of it. Then, I'd select the newly created prefab in the project window and attempt to add a new mount point to the raw prefab itself.

    Doing that left an unparented "MP_New Mount Point" and generated this error:


    Basically what's happening is that Unity won't allow us to parent objects on the raw prefab itself. What we have to do is select a prefab instance, add the new mount point, and then press 'apply'. This will then update the prefab with the new mount point. It seems a bit strange, but that's the rules.

    What I did was update the editor so that the "+" is removed when a prefab is selected in the project panel. I also display a friendly message that explains this. Unfortunately, nothing I can "fix", but I can help you get around it.


    As for the first issue, I'm still trying to duplicate it. No luck so far.

    Can you give me an idea of when the call is made? Is it because of a button press, on a timer, etc. That may help me. I'll keep trying, but if you've got any other info that might help, please feel free to email me at tim@ootii.com.


    Thanks!
     
    Last edited: Oct 29, 2014
  26. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    Alright, cool. I'll try editing my prefabs like that, hopefully it should work.

    Regarding the first issue; yeah it's pretty odd behaviour, as it doesn't happen all the time. Even stranger is that every time I test it I do the exact same process and sometimes it works, other times it fails.

    My setup is there is a body, a head prefab (skinned) and a hair prefab (rigid). I start the project, press A to attach the head, then press S to attach the hair. The hair and body both have a locked MountPoint called "Hair_MP", attached to a bone.

    My calls are:
    Code (CSharp):
    1. head = MountPoints.InstanciateSkinnedMesh(parent, headPrefab);
    2. ...
    3. hair = MountPoints.InstantiateAndConnectPoints(parent, "Hair_MP", hairPrefab, "Hair_MP");
    4.  
    EDIT: Just tested like 50 times and no errors so far! Awesome! Perhaps the errors were connected, and creating the MountPoints on the prefabs *properly* fixed the failing connection. This cleaned up the stray MountPoint objects in the hierarchy too! You rock Tryz!
     
    Last edited: Oct 30, 2014
    Tryz likes this.
  27. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Cool. I'll keep testing along that route.

    EDIT: Awesome! I'll put the update to the editor up in the next couple of days. :)
     
    Last edited: Oct 30, 2014
  28. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    Haven't had a chance to try this asset after buying it about a month ago. It looks like such a fantastic system though.

    Is there any possibility of getting some Playmaker actions for Mount Points? I would love to integrate this into my current workflow!
     
  29. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey DBone,

    I've had a couple of people request Playmaker support for my other assets. I haven't used it before, but I see that it's only $45. I'll pick it up and play with it over the holidays and see what I can do.

    No promises, but I'll look. :)

    Tim
     
  30. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    That's awesome news! Playmaker is a real lifesaver for us artists. At least while I slowly wrap my head around coding...
    Also it seems like if you're going to offer integration with ANY other package, Playmaker is the choice.

    Fingers crossed. Thanks!
     
    Tryz likes this.
  31. observerOne

    observerOne

    Joined:
    Jul 29, 2014
    Posts:
    5
    I was planning on rolling my own snap system for a in game space ship builder. This seems very well done and wondering if it would be simple enough to modify it for my needs. All I really need is the snapping to certain points aspect of it and without parenting them as the parts are being parented. Any more info on this would be great, thanks!
     
    Teila likes this.
  32. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey ObserverOne,

    The snapping logic only works in the editor, but I think it would be pretty easy to copy that logic into the play-time. There's nothing particularly tricky about that part. Mount Points keeps track of the snap points you create on each object and then manages the parenting based on distance (during a drag).

    All the code is pretty modularized. So, commenting out the parenting parts should just be a line of code at the end of the snapping move.

    I hope that helps,
    Tim
     
    observerOne likes this.
  33. observerOne

    observerOne

    Joined:
    Jul 29, 2014
    Posts:
    5
    Thanks for the fast response. I went ahead and purchased it, and I must say its some nice and clean code. I seem to have everything working the way I want it. I have one small issue I can't seem to figure out, what defines the target that will do the snap to? I mean most of the time its working as I expect and on release of the object that I am currently moving it will find the closest point and snap to it. But sometimes if I have moved another object before hand, other objects are snapping instead of the one which is currently moving.

    I have everything set to accept children as these are just all a bunch of parts that will build one thing and anything can go with anything else. Atm I have it set to clear all Scene points and positions at the beginning of the move and it re finds all the mountpoints , next Ill set it up to just load/delete each mount point in a list as we add parts.

    But would really like some insight on how it chooses which object its moving on the snap, it's probably staring me in the face..

    Thanks.
     
  34. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Thanks for the support ObserverOne! :)

    I think I follow what you're saying. Look in the MountPointEditor.cs and you'll see a function FindSnapPoints(). That's the function that tests for close mount points.

    I actually cycle through all the mount points in the list and connect the closest ones, not just the one last modified. I'm thinking that's what you're seeing.

    I need to think about why I did it that way. Seems like we should be able to test the last one that moved and not cycle through all of them. hmmm...
     
  35. observerOne

    observerOne

    Joined:
    Jul 29, 2014
    Posts:
    5
    Yea I'm using"FindSnapPoionts(); , I just created my own script with what i needed from in MountPointsEditor as some of it I need at run time and have no access to Editor. I actually just figured it out. What I did was as you suggested and commented out the parenting of the actual game object , because of the way I am serializing the data to save the ship designs it was confusing some of my code with the nested parts.

    But what I didn't comment out was the way it defines a parent/child relationship to the actual Mountpoint. So anytime I connected a piece a object for the first time, it now had that relationship and would move the child to parent on move.

    All and all its a fantastic system you have here and I'm sure I could build on it when I need more functionality. Haven't really had the time to figure out how I will show the actual mount points in game, but so far you've save me a ton of time!
    Thanks again.
     
  36. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Awesome! :)

    I do have some code I use for drawing object dynamically in a scene; sphere, pyramids, etc. Nothing fancy, but I'm happy to share if it will help.

    Just shoot me an email at tim@ootii.com if you're interested.
     
  37. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    Did you manage to have a look at making Playmaker actions? Give it to me straight, I can take it. :p
     
  38. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    haha... Unfortunately, no :(

    I apologize a thousand fold!!!

    I got wrapped up in some contract work and just didn't get to it. Instead of lying to you again, it's better that I just say "I'm not sure when I can get to it."

    Now, if you think it's something you might be interested in tackling, shoot an email to tim@ootii.com and maybe we can work something out. ;)
     
  39. Dbone

    Dbone

    Joined:
    Mar 10, 2014
    Posts:
    56
    I wish I could do the programming end, but sadly I'm not there yet :(. Fortunately. grinding through problems until they bow before me is my specialty, so I'll figure out how to fit Mount Points into my project. :p

    Cheers, thanks for the great assets!
     
  40. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    hahaha... Tenacity is a great specialty to have.

    If you get stuck or just need some advice, please don't hesitate to email me. I'm happy to help.
     
  41. RealSoftGames

    RealSoftGames

    Joined:
    Jun 8, 2014
    Posts:
    220
    hi i have a few questions for you, i have Atavism online an MORPG Engine, is mount points support Multiplayer, sounds tupid i know i am pretty sure it should as it would work perfectly fine with RPG elements, reason is before i purchase Atavism already has character slots set up, all i would have to do is attach your asset to the selected gear slots.

    checking the Web Demo looks promissing as it works with mesh as well. how does it perform with Different scaled meshes? e.g male and female characters in the breast area, also with other races?

    and also i seen this asset on sale a few months ago, and have been looking for it over the last week pulling my hair out trying to find it.

    perhaps your not reaching a big enough audiance because its so well hidden in the asset store, perhaps a suggestion to change how it is found within the asset store, Name, Meta tags etc. it also doesn't seem to exist anywhere within the Forums as well when i was looking up ways to attach items to a character. just a heads up to try and gain a bigger crowd

    also one last thing, how does it go about the hidden veracities? when attaching a shirt pants etc. what happens to the players body underneath? is it removed and replaced with the Clothing mesh, or does the clothing mesh just go on top of it?

    only reason i found it right now is literally by accident, lucky me i spose!
     
    Last edited: Feb 12, 2015
  42. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey,

    First... wow. I didn't realize it was so well hidden. I'm a much better programmer than marketer, but I'll look into this. What keywords were you using to search for? That my help me.

    As far as multiplayer, there shouldn't be any issue. Everything is tied to the character that Mount Points is part of.

    Supporting skinned meshes is really a matter of the bones. So, if your character scales up, his bones do, and the skinned meshes will too. However, that's a bit different than deformation (ie male breasts going to female breasts). There's nothing that would do this automatically.

    I did play with UMA for a while and was looking to support that, but I never got around to it.

    As for the player body or underlying meshes, I leave that up to the developer. I don't remove anything with Mount Points. In my game, I actually track areas and have a default mesh (ie "skin" chest) that I remove and re-add. So, in this way, I didn't really build Mount Points as an inventory system as much as a way of doing the actual placement of objects.

    I hope that helps.
     
  43. RealSoftGames

    RealSoftGames

    Joined:
    Jun 8, 2014
    Posts:
    220
    ahh yes one most important fact i forgot my self at 2am haha,

    mesh attatchment
    armour/weapon attaching system
    deformable equipment

    and mainly google to search

    how to attach items to a player in unity
    how to equip items to your character in unity
    equipment system in unity
    best assets for equipping items to your character in unity
    how to make an item attach to your player
    ---------------------------------------------------------------------------
    mainly ways to thatch items to your player, thats what comes to my mind when i think about this asset. and i think it would do insanely well if devs where able to find it with simpler terminology, i had searched up several different ways much more than what i had listed but i can not remember the terminology, perhaps you would know of it.

    any possible way to attatch an item to your character where the mesh would also attatch and deform with it during an animation.


    hope this helps, it was a bumber it took me by accident to find it again was searching for it for a long time haha
     
  44. RealSoftGames

    RealSoftGames

    Joined:
    Jun 8, 2014
    Posts:
    220
    so theoretically i would need to make the same armour set for both male and female characters for them to act appropriately?

    as in regards thats how UMA handles meshes, uses the same armour for several different races, would you be interested in supporting this? would save a hell of a lot of time in modelling new pieces for all the different races and doubling the load for male to female characters,

    or perhaps you know of a way already or anyone else that is able to help out with doing that with mount points.
     
  45. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    With skinned meshes (like the pants in the demo), they will move with animations. The trick is when you create the skinned meshes, you tie them to bones in something like Maya.

    I believe what UMA does is that it scales the bones it creates for the different races. If that's the case, then when Mount Points assigns the skinned mesh it would scale automatically. In this case, the skinned mesh would be tied to the bones that UMA uses.

    I'm afraid it's been about 6 months since I've looked into UMA. It will take me about a week, but once I get some time, I'll try creating pants for UMA and see how that goes.

    I actually wrote about this in my blog:
    http://www.hallowsdeep.com/clothing-workflow/
     
  46. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    30
    Hi!

    I have scripting issues, i hope you can help me.

    I have an inventory system, and when i equip the armor it runs this script:

    void Equip()
    {
    MountPoints.InstanciateSkinnedMesh(GameObject.Find("Player"), "Prefabs/Armor/Shirts/Cloth-Underwear-Upperbody");
    }

    It works great, it attaches the mesh to the bones. My problem is i cant reference to this created object, because im not that good with code. This script has another function: Unequip. I know that i had to destroy that object with Destroy(gameObject); but i cant reference to it... Thanks your answer!


    void UnEquip()
    {

    //Finds an object you want to destroy called "Cloth-Underwear-Upperbody(Clone)" or any other name
    GameObject.Find("Cloth-Underwear-Upperbody(Clone)");
    Destroy(gameObject);

    }
     
  47. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Ah, you are sooooo close. :)

    The MountPoints.InstanciateSkinnedMesh() call actually returns the GameObject that represents the object you created.
    Code (CSharp):
    1. GameObject lNewObject = MountPoints.InstanciateSkinnedMesh(GameObject.Find("Player"), ...);
    So, you could handle this a couple of way...

    1. You could use the new GameObject and change it's name. Then you could search for it by name later.

    2. You could store the GameObject reference directly.

    This way, your inventory system would track what is currently active and allow you to change or destroy it later.

    Hope that helps
     
    nitoh likes this.
  48. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    30
    I solved it.. it was soo easy.... and it took me like 2 hours, to figure it out, but you helped me a lot.. Thanks!!!
     
  49. MrAdventure

    MrAdventure

    Joined:
    Aug 22, 2012
    Posts:
    28
    Hello,

    I am having an issue that I think has to to with changing the size of the parent after having assigned it a mount point.

    In my game, I've got plants that grow from a very small size, then instantiate fruit on them at the mount points I've defined.

    The fruit WILL be, but is not as yet, starting out very small and growing.

    My steps:

    1) Apply Mount Point to Prefab at 0, 0, 0 local, for both Parent and Child.
    2) Instantiate Parent Prefab with a size of .001, .001, .001.
    3) Transfer localScale of Parent up for a set time.
    4) Instantiate Child on Parent.

    The Child does not appear on, or anywhere near, the Parent. The following error is thrown:

    Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.

    Line 290 in MountPoint.cs
    I did a little bit of playing around, and got errors in the editor by applying the Parent Mount to the Prefab of size .001, .001, .001, then manually changing its size to .5, .5, .5, and manually attaching the Child. It throws the following error in Editor:

    transform.localScale assign attempt for 'MP_MountPoint0' is not valid. Input localScale is { Infinity, 999.999939, 999.999939 }.

    I realize that this may not be something that can be fixed, due to the extremely small size, but was wondering if you had any thoughts on the matter.

    Thanks,

    Victor
     
  50. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,402
    Hey Victor,

    Ok, you had me curious. So, I created a scene like what you described:


    I created a tree (cylinder) and a fruit (sphere). I added a Mount Point to each. Then I made them both prefabs and deleted the fruit from the scene.

    When I press the button, the tree grows a bit. Then the fruit is instantiated and starts to grow. Both continue to grow, but independent of each other.

    What I learned...

    1. For the "prevent data corruption", I'm not seeing that. However, I think you're actually working with the fruit prefab and not the instance of the fruit. I believe that error is basically saying we can't assign a parent on the prefab because prefabs don't live in the scene.

    2. For the scale, the mount point inverts the scale of the parent so the child's scale is basically nullified. For example: if your tree has a scale of "0.001", the mount point will have a scale of 1000 since 0.001 x 1000 = 1.0. That's how I make the child's scale independent of the parent.

    I believe the scale on the parent (tree) has a 0 in it. Which would make the scale of the mount point infinity. Hence, the error. I need to prevent this in code, but you can probably work around it by ensuring the scale is never set to 0.

    In case you're interested, here's the code I tested with...
    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 FruitGrowTime = 3f;
    16.  
    17.     public float FruitMaxSize = 0.25f;
    18.  
    19.     private bool mTreeGrowing = false;
    20.  
    21.     private bool mFruitGrowing = false;
    22.  
    23.     private float mElapsedTreeGrowTime = 0f;
    24.  
    25.     private float mElapsedFruitGrowTime = 0f;
    26.  
    27.     private GameObject Fruit = null;
    28.  
    29.     // Use this for initialization
    30.     void Start ()
    31.     {
    32.  
    33.     }
    34.  
    35.     // Update is called once per frame
    36.     void Update()
    37.     {
    38.         if (Tree == null) { return; };
    39.  
    40.         if (mTreeGrowing && mElapsedTreeGrowTime < TreeGrowTime)
    41.         {
    42.             mElapsedTreeGrowTime += Time.deltaTime;
    43.  
    44.             // Grow the tree
    45.             float lScale = mElapsedTreeGrowTime / FruitGrowTime;
    46.             if (lScale > 0f)
    47.             {
    48.                 Tree.transform.localScale = new Vector3(lScale, lScale, lScale);
    49.             }
    50.  
    51.             // Instanciate and grow the fruit
    52.             if (Fruit == null && mElapsedTreeGrowTime >= TreeBloomTime)
    53.             {
    54.                 Fruit = MountPoints.InstantiateAndConnectPoints(Tree, "Branch 1", "Prefabs/Fruit", "Branch 1");
    55.  
    56.                 mFruitGrowing = true;
    57.                 mElapsedFruitGrowTime = 0f;
    58.             }
    59.         }
    60.  
    61.         if (Fruit != null && mFruitGrowing && mElapsedFruitGrowTime < FruitGrowTime)
    62.         {
    63.             mElapsedFruitGrowTime += Time.deltaTime;
    64.  
    65.             // Grow the tree
    66.             float lScale = mElapsedFruitGrowTime / FruitGrowTime;
    67.             if (lScale > 0f)
    68.             {
    69.                 lScale *= FruitMaxSize;
    70.                 Fruit.transform.localScale = new Vector3(lScale, lScale, lScale);
    71.             }
    72.         }
    73.     }
    74.  
    75.     /// <summary>
    76.     /// Place the buttons and send messages when clicked
    77.     /// </summary>
    78.     void OnGUI()
    79.     {
    80.         if (GUILayout.Button("Grow"))
    81.         {
    82.             if (Fruit != null)
    83.             {
    84.                 GameObject.DestroyImmediate(Fruit);
    85.                 Fruit = null;
    86.             }
    87.  
    88.             mTreeGrowing = true;
    89.             mElapsedTreeGrowTime = 0f;
    90.  
    91.             mFruitGrowing = false;
    92.             mElapsedFruitGrowTime = 0f;
    93.         }
    94.     }
    95. }
    96.  
    I hope that helps. Please let me know if it doesn't.
     
    Last edited: Apr 8, 2015