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

Jelly Sprites - Soft body sprite physics system

Discussion in 'Assets and Asset Store' started by mrsquare, Dec 5, 2013.

  1. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hi folks,

    I'm pleased to announce the release of Jelly Sprites on the Unity Asset Store :)

    Web Player Demo

    Tutorial Video

    Jelly Sprites is a soft-body physics system for Unity and 2D Toolkit sprites, It allows you to quickly and easily convert static sprites into ones that will bounce, stretch and deform, naturally reacting to physical forces in your game.

    * Works with Unity and 2D Toolkit sprites.
    * Supports both 2D and 3D physics systems.
    * Simple to configure, but with in-depth configuration options to let you easily balance quality and performance.
    * Supports rectangular, circular, triangluar and grid body configurations.
    * Attach point system allows child object positions to react to physics forces just like the visible render mesh.
    * Full C# source code and example scene included.


    To create a Jelly Sprite, you simply create a Jelly Sprite GameObject, drag a Unity (or 2D Toolkit) sprite onto it, and then hit play! Jelly Sprites work by creating a set of rigid bodies and circle colliders, attached by springs, the movement of which is then translated into the rendered mesh of the sprites. As the bodies stretch and distort, so do your sprites.

    Jelly Sprites come with numerous options to configure everything from the spring stiffness and mass of the bodies to the physical layout of the colliders - you can make things as bouncy or as rigid as you want. Check out the tutorial video for more info.



    I hope this proves helpful to some people out there! Please feel free to reply in this thread or PM me if you have any questions :)


    (If you'd like to create a similar sort of effect, only with 3D meshes instead of sprites, then check out my Jelly Mesh plugin!)
     
    Last edited: Mar 3, 2014
    Gozdek likes this.
  2. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    WOW ! It's wonderful and so dynamic !!!!!!!!!!!!!!!!!!!!!!!!
    A fantastic use of Unity2D ! Congratulations !
    6R
     
  3. gtjuggler

    gtjuggler

    Joined:
    Nov 13, 2008
    Posts:
    238
    This is great!!
     
  4. Kurius

    Kurius

    Joined:
    Sep 29, 2013
    Posts:
    412
    Awesome!
    Question... could this be used to simulate water, such as the water in Where's My Water? Can multiple "jellies" slightly overlap each other like water droplets accumulating? How many "jellies" can be added to a scene before you start to experience performance issues? Thanks!
     
  5. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - you could use this for water I guess, but what you're describing is really a metaball shader/rigid body simulation (basically lots of little individual spheres, but the shader blends nearby ones together so that they look like blobs. I haven't used it personally, but I think Fluvio supports this (
    ).

    Regarding performance - each blob is roughly 4 rigid bodies, and 4 springs (depending on which configuration you choose), so performance is totally down to the 2D physics engine. My PC (old-ish i5) can run ~90 Jelly Sprites in the demo scene and it keeps a steady 30fps, but on a mobile device you'll probably be limited to much less, I'd imagine. I'll try to do some performance tests on my iPhone 4S and get back to you.
     
    Last edited: Oct 29, 2014
  6. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    e-mail sent...
    6R
     
  7. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    I have a lot of pleasure playing with Jelly characters : Octopuss, Blob,...

    Questions :
    * Is it possible to change the Sprite per C# script (at runtime) ? I wanted to use the Spriterenderer like your eyes but it is in conflict with the Mesh renderer here !?!
    * Is it possible to block a sprite in the air to build a kind of Wooden bridge with several jelly sprites or one jelly sprite showing a wooden bridge and a grid Body configuration for example ?
    Thanks,
    6R
     
  8. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    What a great asset! Congratulations on the release. It seems amazing from the demo.
     
  9. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Currently you can't change the sprite at runtime, no - this would be easy to add though, I'll take a look. One restriction - the new sprite will need to be the same dimensions as the original sprite or else it will look squashed/stretched. It should work fine if you just want to add animation frames to the sprite or something like that :)

    You could definitely create a bridge like structure, yep. If you create a Grid style JellySprite with lots of points, and then set a horizontal row of the rigid bodies to be Kinematic, then it will float in the air but will still be wobbly. I tried it out in the demo just now and got something like this working pretty easily:

    $Bridge.png

    Would probably look much better if I increased the spring stiffness to make it more rigid, but you get the idea. To achieve that, just add this JellyBridge script to any JellySprite Gameobject.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. [RequireComponent (typeof(JellySprite))]
    6. public class JellyBridge : MonoBehaviour
    7. {
    8.     public float fixedRowFraction = 0.5f;
    9.     bool isFirstUpdate = true;
    10.    
    11.     // Update is called once per frame
    12.     void Update ()
    13.     {
    14.         // Need to wait until the jelly sprite has initialised
    15.         if(isFirstUpdate)
    16.         {
    17.             JellySprite jellySprite = GetComponent<JellySprite>();
    18.  
    19.             if(jellySprite.m_Style == JellySprite.PhysicsStyle.Grid)
    20.             {
    21.                 // Work out the row of rigidbodies to fix - so 0.5 means halfway
    22.                 int fixedRow = (int)(jellySprite.m_GridRows * fixedRowFraction);
    23.                
    24.                 for(int x = 0; x < jellySprite.m_GridColumns; x++)
    25.                 {
    26.                     // Work out the point index in the array from the x and y index
    27.                     int pointIndex = (fixedRow * jellySprite.m_GridColumns) + x;
    28.                    
    29.                     // Check its not a dummy point
    30.                     if(jellySprite.ReferencePoints[pointIndex].GameObject)
    31.                     {
    32.                         // Set kinematic (might be a 2D or 3D point, so check for both
    33.                         if(jellySprite.ReferencePoints[pointIndex].GameObject.rigidbody)
    34.                         {
    35.                             jellySprite.ReferencePoints[pointIndex].GameObject.rigidbody.isKinematic = true;
    36.                         }
    37.                        
    38.                         if(jellySprite.ReferencePoints[pointIndex].GameObject.rigidbody2D)
    39.                         {
    40.                             jellySprite.ReferencePoints[pointIndex].GameObject.rigidbody2D.isKinematic = true;
    41.                         }
    42.                     }
    43.                 }
    44.             }
    45.             else
    46.             {
    47.                 Debug.LogWarning("JellyBridges can only be used on JellySprites using a Grid style configuration");
    48.             }
    49.  
    50.             isFirstUpdate = false;
    51.         }
    52.     }
    53. }
    54.  
    Changing the 'Fixed Row Fraction' variable in the inspector will change which row of rigid bodies is made kinematic (so 0.0 means the bottom row, 0.5 means halfway up, 1.0 means the top row, etc)
     
    Last edited: Dec 10, 2013
  10. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Yeah ! It works fine !!!! Congratulations and Thank you !!!
    And there are so many possibilities for a Bridge or Water... Thanks a lot !

    Yes, I thought it could be interesting for another sprite made in another direction to avoid Flip Horizontal but to allow a sprite with other shadows for example. I mean we could draw a sprite with the shadow on the left side and another similar one with the shadow on the right side, following the direction the sprite moves !
    And sure it could be useful for simple animations....
    Let me know when you have added this, please.

    Try to play with this JellyBridge script and the parameters of your Logo sprite... Very funny !!!

    Thanks a lot for all your help and support !
    6R
     
    Last edited: Dec 10, 2013
  11. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    I bought this now but after importing i get this yellow masse:
    Assets/JellySprites/Editor/JellySpriteEditor.cs(279,88): warning CS0618: `UnityEditor.EditorGUILayout.ObjectField(string, UnityEngine.Object, System.Type, params UnityEngine.GUILayoutOption[])' is obsolete: `Check the docs for the usage of the new parameter 'allowSceneObjects'.'

    and this red one:
    CompareApproximately(dstRatio, srcRatio, 1.0f/32.0f)

    but the demo scene is running :)

    It is so nice to play with it :)
     
  12. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    I've now submitted a fix for this. Its not critical though, you're fine to ignore it :)

    This looks like a Unity bug - somebody else reported it the other day. I think it's just something weird about my demo scene's assets - doesn't seem to cause any problems, so you should be fine to ignore it for now.

    I just tested out swapping sprites at runtime. All you need to do is call this from a component attached to the JellySprite:

    Code (csharp):
    1.  
    2. UnityJellySprite jellySprite = GetComponent<UnityJellySprite>();
    3. jellySprite.m_Sprite = *NEW SPRITE*;
    4. jellySprite.RefreshMesh();
    5.  
    There is a bug where the new graphics will appear at an incorrect position for a single frame after doing this - I've submitted an update to fix that, but if you want to make the fix yourself, you can simply change RefreshMesh() in JellySprite.cs to this:

    Code (csharp):
    1.  
    2. /// <summary>
    3. /// Called when the editor wants to update the visible mesh
    4. /// </summary>
    5. public void RefreshMesh()
    6. {
    7.     if(IsSpriteValid())
    8.     {
    9.         InitVertices(GetSpriteBounds());
    10.         InitMaterial();
    11.         InitMesh();
    12.  
    13.         if(m_ReferencePoints != null)
    14.         {
    15.             CalculateWeightingValues();
    16.         }
    17.  
    18.         UpdateMesh();
    19.     }
    20. }
    21.  
    (so I've just added a call to 'UpdateMesh()' at the end)
     
  13. tloechelt

    tloechelt

    Joined:
    Dec 13, 2013
    Posts:
    5
    Thx for this awesome tool mr. mrsquare. I bought it and played around with it the last two days. I added a "free" Body Configuration to allow non uniform collider positions better matching organic forms. Was quit easy due to your well organised code but what i didn't managed so far is to add a working "rotation" property for the sprite just like the Sprite Scale. That would be very useful. Thats maybe something for the next update ;)
    One last question, do you plan to support the optimised, unity generated mesh in the future?
     
  14. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Thanks - glad you like it! :) Your 'Free' configuration sounds interesting - are you letting the user manually position the colliders in the scene view, or does it do it automatically based on the sprite shape?

    I'm not sure I know exactly which optimised meshes you're referring to here - I'd like to add in support for automatically trimming grid vertexes based on the sprite's alpha values though, in case you mean something like that :)
     
  15. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Thanks a lot mrsquare...
    It works perfectly !!!!!!!!!!!!!!!!!!!!!!

    @tloechelt : Any chance you give your "free" Configuration to mrsquare to add to the plugin for a next update and for all users ?

    6R
     
  16. tloechelt

    tloechelt

    Joined:
    Dec 13, 2013
    Posts:
    5
    exactly! I have NumFreeCollider value which defines how many knots i need. Positioning is done by Unity Handles directly in the scene view.

    I also added a center offset value for the reference point (center is used by default)

    Sure i can provide my modifications to mrsquare but i guess he can easily implement it himself ;)
     
  17. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Great news tloechelt... Hope all users can benefit of it as soon as possible...
    Thanks a lot !
    6R
     
  18. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey all - I've now implemented a 'Free' mode to let you manually configure the position and size of each collider. Many thanks to tloechelt for the idea :)

    If you import the latest version of the package from the Asset Store, you can now select 'Free' from the body configuration list. When in Free mode, you can grab the individual bodies in the scene view and move them around, and also scale them up or down. You can also add and delete nodes via the inspector.

    I've also added functionality to convert an existing shape into a 'Free' shape, so you can quickly set up your Jelly Sprite in a circular/rectangular/whatever configuration and then convert it to Free mode and make the final few tweaks. Here's how to do it:

    $JellySpritesFree1.png
    First, configure your Jelly Sprite as normal, then click the 'Copy Configuration To Free Mode' button in the inspector


    $JellySpritesFree2.png
    Notice that the Body Configuration type has now changed to say 'Free', and you can see a list of body positions (x, y) and radius (z) values in the inspector. To add more bodies, click 'Add New Body' and to remove one, just click the '-' sign next to the body.


    $JellySpritesFree3.png
    You can now freely drag the bodies around in the scene view and also scale them up and down.
     
  19. tloechelt

    tloechelt

    Joined:
    Dec 13, 2013
    Posts:
    5
    nice one! its pretty much how i did it except the distinct collider scaling which is very useful. i will check it out. thx
     
  20. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    WOW ! Fantastic !!!
    It works fine !

    Thanks to tloechelt and mrsquare for all of this...
    6R
     
  21. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    I have made this video to show how fantastic the Jelly Sprites plugin is :
    I have used the 2D tutorial and the great help from mrsquare to make it work... Thanks to all !
    6R

     
    wetcircuit likes this.
  22. Acumen

    Acumen

    Joined:
    Nov 20, 2010
    Posts:
    1,041
    Haha that looks supercool.
    Especially considering it looks so 3d-ish, yet it's all flat and no jelly animation ever broke the illusion. Sweet job !
     
  23. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Awesome - that looks really cool! Glad you're finding it useful :D
     
  24. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Thanks a lot...
    With a good plugin we can do nice things !
    6R
     
  25. tumtubs

    tumtubs

    Joined:
    Sep 5, 2013
    Posts:
    1
    Hi,
    Is there any way to get all the "Jellysprite Ref Point"s to be created before the game starts?
     
  26. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hiya - not currently, although I'm hoping to add this as an option soon as its been requested by a few people. If you're wanting to add custom behaviour to the reference point GameObjects, then for the time being the best thing to do is to just add a script to the Jelly Sprite that loops through all its reference points on the first update frame and manually adds and the components.

    I'm just waiting for the 1.09 update to go through review, but should be able to get started on this once that's out the way.
     
  27. nigelloNZ

    nigelloNZ

    Joined:
    Jan 3, 2014
    Posts:
    1
    Hi, Just wondering how to detect a mouse click on the Jelly Sprite?, the usual way doesn't work, tried adding a collider and using OnMouseUp etc

    Thanks heaps
     
  28. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Heya,

    The new 1.09 update will hopefully fix this - the location of the parent Jelly Sprite GameObject should now be where the centre of the visible mesh is located (rather than remaining static as it does now), so you do stuff like attach a trigger collider to the Jelly Sprite and it'll track the position correctly.

    Unfortunately the Unity QA team seem to be off for the holidays still, so the update is still pending review. If you let me know your email, I can send you an advance copy, otherwise it should hopefully out in a few days :)
     
  29. jlee1003

    jlee1003

    Joined:
    Jan 7, 2014
    Posts:
    1
    Hi mrsquare,
    I had used your jelly sprites, it works great, thanks to your cool job!
    But I had one problem, it seems that the sprite position does not change. For example i Debug.log(m_JellySprite.transform.position), it always shows the origin position, even after i addForce to it.
    so how can i get the right position of it?
    thanx again.
     
  30. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hey - this is the same issue that nigelloNZ was finding. Its fixed already, but I'm still waiting for Unity QA to review the update (I imagine there's a massive queue of things that need reviewing after the holiday period, so it might take a little while unfortunately).

    Let me know your email address and I can forward you an advance copy :) Alternatively, just do this for the time being:

    Code (csharp):
    1.  
    2. Debug.log(m_JellySprite.ReferencePoints[0].GameObject.transform.position)
    3.  
    which will give you the position of the central rigid body of the Jelly Sprite.
     
  31. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hi everyone,

    Jelly Sprites 1.14 is now live in the Asset Store! This contains some nice new improvements:


    Positioning

    Previously, the parent Jelly Sprite GameObject would remain static, with only the rigid bodies moving in the world. This has now been fixed so that the Jelly Sprite GameObject will move around as the visible mesh does. This means that you can do stuff like attach trigger colliders to the Jelly Sprite, and they'll move around as you'd expect.

    Rotation

    Jelly Sprites can now rotate! This behaviour is disabled by default, but easily enabled via the Inspector controls

    Attach Points

    Jelly Sprites now support being attached to one another, so they can bounce around in unison.

    Kinematic Points

    You can now use the Inspector to set the central body of the Jelly Sprite to be kinematic, essentially fixing the Jelly Sprite in place while still retaining its bouncy properties. When in 'Free' mode, you can choose to make any of the rigid bodies kinematic, allowing you to easily create create custom bouncy structures.

    Scaling

    There is a new scaling function that you can use to scale up/down your Jelly Sprite at runtime. Simply call eg.

    Code (csharp):
    1.  
    2. jellySprite.Scale(0.5f);
    3.  
    Triggers

    Whenever a rigid body owned by a Jelly Sprite receives an OnCollisionEnter/OnCollisionExit/OnTriggerEnter etc. message, it will now forward that on to the parent Jelly Sprite. This means that you can easily listen out for and respond to collision events in any behaviour attached to the Jelly Sprite. To use, simply implement eg.

    Code (csharp):
    1.  
    2. void OnJellyCollisionEnter(JellyCollision collision)
    3. {
    4. }
    5.  
    6. void OnJellyTriggerExit(JellyCollider collider)
    7. {
    8. }
    9.  
    The functions are named exactly the same as their Unity counterparts, only prefixed by the world 'Jelly', and exist in both 2D and 3D variants. The JellyCollider/JellyCollision parameters that are passed through will contain the original Unity collision parameter, along with a reference to the Jelly Sprite Reference Point that reported the collision.

    Attach To Neighbour

    You can now optionally attach Jelly Sprite Reference Points to their neighbouring points as well as to the central point. This should create a more structurally sounds Jelly Sprite with less wobble, which may be useful in certain situations.



    As always, let me know if you have any problems, I'd be happy to help you fix them :) The Webplayer demo has now been update to demonstrate the rotating Jelly Sprites, along with parenting one Jelly Sprite to another (in the case of the two orange blobs)

    $JellyScreen.png
     
    Last edited: Jan 8, 2014
  32. uCommando

    uCommando

    Joined:
    Jan 9, 2014
    Posts:
    3
    Very nice product but I need unity 4.2 support. Is there a plan for it ?
     
  33. AdamOwen

    AdamOwen

    Joined:
    Jul 13, 2011
    Posts:
    66
    This looks fantastic! I'm interested in picking it up, would appreciate it if you could answer a couple of quick questions.

    I'm only developing for mobile (Android now, iOS later) and it'd be good to get an idea of performance for something like the demo scene if you've gathered any yet, iOS data would be fine I just want to make sure I'll be able to make use of the asset. Also, the attach points function looks like something I would find useful, can you create these at runtime when jelly sprites collide with each other?

    Thanks and great work again, hope to play around with it soon!
     
  34. MLH1407

    MLH1407

    Joined:
    Sep 11, 2008
    Posts:
    13
    with attach points - do you then mean that one could attach children jellies onto the main jelly ? i tried to make that work with no luck - and maybe i missed how it should be done ? can you explain that ? thanks
     
  35. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hi all,

    There isn't really any reason (as far as I know) why this wouldn't work in 4.2, but it might need a little bit of fiddling to get the code compiling. Firstly, you'd need to be using 2D Toolkit (since Unity Sprites weren't around in 4.2), and then you'd also need to remove any references in the Jelly Sprite code to the new 2D physics system (which should be pretty trivial - I can do this/talk you through it if you need).

    If you do buy the asset and can't get it working, do let me know as I'm fairly sure that I can get you a refund

    I haven't done any mobile profiling yet, but I've got an iPhone 4S so will give it a try this weekend and get back to you. I know a few folk have been using it on mobile quite happily though (going by Asset Store reviews) - the main CPU cost is going to be simulating the springs and rigid bodies, so provided you keep them to sensible numbers (no 25 x 25 grids or anything like that!) then I'd hope that performance shouldn't be much of a concern.

    I've not tried creating an attach point dynamically, but see no reason why you couldn't. I'm going to be doing some work on the asset this weekend, so I'll put in a handy function to let you attach new objects at runtime.

    Have you got the latest update (1.14)? Attaching Jelly Sprites to other Jelly Sprites didn't work correctly before, but it should be supported now. If you open up the demo scene, the two Orange Blobs are attached to one another - just look at the big Orange Blob in the inspector and you should see the small one in the list of Jelly Sprite attach points. You just attach them as you would with any other GameObject.
     
  36. M.J.

    M.J.

    Joined:
    Jan 10, 2014
    Posts:
    2
    I found one point to improved performance.
    UpdateMesh of JellySprite.cs is most heavy point.

    There are 2 for loop, but it calculate same thing(calculation of offset) many times.
    So I changed as follows to calculate it only once.

    Code (csharp):
    1.  
    2.     void UpdateMesh()
    3.     {
    4.         // For each vertex, look at the offset values of each reference point and apply the same offset
    5.         // (scaled by the weighting value) to the vertex's position
    6.         if(Application.isPlaying)
    7.         {
    8.             // !!! Calculate offset calculation out of loop
    9.             Vector3[] baseOffsets = new Vector3[m_ReferencePoints.Count];
    10.             for(int referencePointIndex = 0; referencePointIndex < m_ReferencePoints.Count; referencePointIndex++)
    11.             {
    12.                 if(!m_ReferencePoints[referencePointIndex].IsDummy  m_ReferencePoints[referencePointIndex] != m_CentralPoint)
    13.                 {
    14.                     ReferencePoint referencePoint = m_ReferencePoints[referencePointIndex];
    15.                     Vector3 offset = m_CentralPoint.GameObject.transform.InverseTransformPoint(referencePoint.GameObject.transform.position);
    16. //                  Vector3 offset = centralTransform.InverseTransformPoint(m_ReferencePointTransforms[referencePointIndex].position);
    17.                     offset -= referencePoint.InitialOffset;
    18.                     baseOffsets[referencePointIndex] = offset;
    19.                 }else{
    20.                     // If it's dummy, set offset as zero.
    21.                     baseOffsets[referencePointIndex] = Vector3.zero;
    22.                 }
    23.             }
    24.  
    25.             for(int vertexIndex = 0; vertexIndex < m_Vertices.Length; vertexIndex++)
    26.             {
    27.                 Vector3 totalOffset = Vector3.zero;
    28.                 for(int referencePointIndex = 0; referencePointIndex < m_ReferencePoints.Count; referencePointIndex++)
    29.                 {
    30.                     // !!! Move offset calculation out of loop
    31. //                  if(!m_ReferencePoints[referencePointIndex].IsDummy  m_ReferencePoints[referencePointIndex] != m_CentralPoint)
    32. //                  {
    33. //                      ReferencePoint referencePoint = m_ReferencePoints[referencePointIndex];
    34. //                      Vector3 offset = m_CentralPoint.GameObject.transform.InverseTransformPoint(referencePoint.GameObject.transform.position);
    35. //                      offset -= referencePoint.InitialOffset;
    36. //                      totalOffset += offset * m_ReferencePointWeightings[vertexIndex, referencePointIndex];
    37.                         totalOffset += baseOffsets[referencePointIndex] * m_ReferencePointWeightings[vertexIndex, referencePointIndex];
    38. //                  }
    39.                 }
    40.                
    41.                 m_Vertices[vertexIndex] = m_InitialVertexPositions[vertexIndex] + totalOffset;
    42.             }
    43.            
    44.             // Update the mesh
    45.             m_SpriteMesh.vertices = m_Vertices;
    46.             m_SpriteMesh.RecalculateBounds();
    47.             m_SpriteMesh.RecalculateNormals();
    48.         }
    49.     }
    50.  
    Previously, my prototype's fps on iPhone4S was around 10.
    But now, it's around 40.
    I'm happy if this is helpful for you:)
     
  37. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Ah, excellent, thank you, that was a bit of an oversight - I'll definitely roll that into the next update :)

    Even better would be to just create the baseOffsets array as a member variable when the Jelly Sprite is created, that way you won't generate any garbage by creating a new array every frame.
     
    Last edited: Jan 10, 2014
  38. MLH1407

    MLH1407

    Joined:
    Sep 11, 2008
    Posts:
    13
    aah my bad i forgot to update the project now its working - ill give it a try - thanks
     
  39. uCommando

    uCommando

    Joined:
    Jan 9, 2014
    Posts:
    3
    In asset store it states : "Requires Unity 4.3.2 or higher." and I couldnt buy and download it :(
    I have TK2D and looking forward to buy this nice product.
     
  40. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Hm, sorry to hear that, must be a Unity restriction then.

    If you'd like to purchase it direct from me, you can pay for it by Paypal if you'd like? Just use the support email address on my publisher page. I'll do a pass over the code to make it properly 4.2 compatible before I send it to you :)
     
  41. uCommando

    uCommando

    Joined:
    Jan 9, 2014
    Posts:
    3
    Hi ..

    Thanks for support. I have sended via paypal.

    Looking forward to use this product ...
    Thanks for such a lovely product. Really good job.

    bb.
     
  42. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Cool - just sent you the package, thanks!

    If anyone else is interested in a Unity 4.2 compatible version, just get in touch :)
     
  43. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    The 1.16 update is now live on the Asset Store - amongst a few other things, it includes the performance optimisations that M.J suggested, so well worth the update if you're still using an older version.
     
  44. M.J.

    M.J.

    Joined:
    Jan 10, 2014
    Posts:
    2
    I found one more possibility to improve performance if some jelly are not moving.
    Now, all vertices of mesh are calculated every frame, but if all offset of control points are not changed from previous frame it is not needed.
    How about to check whether is it changed or not ?

    Code (csharp):
    1.  
    2. if(Application.isPlaying)
    3.         {
    4.             bool referencePointMoved = false;
    5.             // Calculate reference point offsets
    6.             for(int referencePointIndex = 0; referencePointIndex < m_ReferencePoints.Count; referencePointIndex++)             
    7.             {          
    8.                 Vector3 offset = Vector3.zero;
    9.                 if(!m_ReferencePoints[referencePointIndex].IsDummy  m_ReferencePoints[referencePointIndex] != m_CentralPoint)                  
    10.                 {                  
    11.                     ReferencePoint referencePoint = m_ReferencePoints[referencePointIndex];                
    12.                     offset = m_CentralPoint.GameObject.transform.InverseTransformPoint(referencePoint.GameObject.transform.position);
    13.                     offset -= referencePoint.InitialOffset;            
    14.                 }
    15.  
    16.                 if(m_ReferencePointOffsets[referencePointIndex] != offset){
    17.                     m_ReferencePointOffsets[referencePointIndex] = offset;
    18.                     referencePointMoved = true;
    19.                 }
    20.             }
    21.             if(!referencePointMoved){
    22.                 return;
    23.             }
    24.  
    25.             for(int vertexIndex = 0; vertexIndex < m_Vertices.Length; vertexIndex++)
    26.             {
    27.  
     
  45. devandart

    devandart

    Joined:
    Jun 7, 2013
    Posts:
    144
    This is a really cute asset.
    Do you have planned to integrate Uni2D support out of the box?

    If yes, you have another buyer. :p
     
  46. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Yeah, good plan. It might not kick in very often if you have a particularly bouncy sprite (or if you have any sort of slight physics jitter that is keeping the bodies awake), but it can't hurt to make that check and do an early return. I'll add that in the next update, thanks for the suggestion :)

    Hey - sorry, not at the moment, but only because I'm not familiar with Uni2D. I'll check it out though, so don't rule it out!
     
  47. Brutus2KK

    Brutus2KK

    Joined:
    Feb 3, 2014
    Posts:
    5
    Hi I just bought the tool and have a problem straight out of the box. As soon as I activate the "Use 2D Physics" the JellySprite stops moving at all.

    Known issue?
     
  48. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    Heya - take a look in the console output window - I'm guessing that you have an error message saying something like:

    Layer xxx is set to collide with itself - soft body physics will not work as intended. Please disable collisions between this layer and itself (Edit->Project Settings->Physics 2D)

    Its a workaround for this issue - once Unity have fixed that then I can remove that requirement.
     
  49. Brutus2KK

    Brutus2KK

    Joined:
    Feb 3, 2014
    Posts:
    5
    Thanks for your reply, so what do I do to get things moving ?
     
  50. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    281
    (Excuse the massive pictures!)

    If you click on your Jelly Sprite in the scene view, you can see what layer it is set to:

    $Inspector.png

    Then if you go to Edit->Project Settings->Physics 2D, you'll see a grid of check boxes

    $PhysicsSettings.png

    This grid defines which layers are allowed to collide with one another. You need to set it so that whatever layer the Jelly Sprite is using isn't allowed to collide with itself - so in the screenshots above, the Jelly Sprite is on a layer called 'JellySprite', and I've disabled collisions by unticking the box at the intersection of the horizontal JellySprite layer with the vertical JellySprite layer.

    If you're working in 2D mode and have multiple Jelly Sprites active at once, the best practice is to put each one on its own layer - that way they will work correctly, but can still collide with one another.