Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    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:
    241
    Hey. In BlobEyes.cs, go to line 75,

    Remove these lines:

    Code (csharp):
    1. if(m_LookTarget != null)
    2. {
    3.     desiredLookDirection = m_LookTarget.transform.position - this.transform.position;
    4. }
    5. else
    6. {
    7.     desiredLookDirection = Vector2.zero;
    8. }
    and replace them with this:

    Code (csharp):

    So that basically just turns the mouse position (which is in screen coordinates) into a position in the world, and then sets the eye look direction to be the vector from the eye to the mouse :)
     
    theANMATOR2b likes this.
  2. waseem2bata

    waseem2bata

    Joined:
    Apr 17, 2014
    Posts:
    8
    thanksss dude , any ideas how to make a mouth
     
  3. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Depends what you want it to look like, really!

    If you just create a little 'O' shaped circular sprite, then squash and stretch the transform scale values, then that usually works quite well. Here's a little script that I use in my own games:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class BlobMouth : MonoBehaviour
    5. {  
    6.     public bool IsTalking = true;
    7.     public float TalkSpeedMin = 10.0f;
    8.     public float TalkSpeedMax = 20.0f;
    9.     public float TalkScaleMin = 0.3f;
    10.     public float TalkScaleMax = 0.5f;
    11.  
    12.     Vector3 StartScale;
    13.     float Timer;
    14.     float Speed;
    15.     float Scale;
    16.  
    17.     void Start ()
    18.     {
    19.         StartScale = this.transform.localScale;
    20.         Randomize();
    21.     }
    22.  
    23.     void Randomize()
    24.     {
    25.         Speed = UnityEngine.Random.Range(TalkSpeedMin, TalkSpeedMax);
    26.         Scale = UnityEngine.Random.Range(TalkScaleMin, TalkScaleMax);        
    27.     }
    28.  
    29.     void Update()
    30.     {
    31.         if(IsTalking)
    32.         {
    33.             Timer += Time.deltaTime * Speed;
    34.             float mouthScale = Mathf.Abs(Mathf.Sin(Timer) * Scale);
    35.             this.transform.localScale = new Vector3(StartScale.x, StartScale.y * (1 + mouthScale), StartScale.z);
    36.          
    37.             if(Timer >= Mathf.PI)
    38.             {
    39.                 Randomize();
    40.                 Timer -= Mathf.PI;
    41.             }
    42.         }
    43.     }
    44. }
    So you'd just attach that to a mouth sprite and it'll make it look like it is talking randomly. You can attach the mouth to the Jelly Sprite using the attach point system in the inspector (in the same way that the eyes are attached).
     
  4. weichendigital

    weichendigital

    Joined:
    Oct 13, 2015
    Posts:
    4
    I have downloaded the asset, followed exactly step-by-step on the jellymesh tutorial.

    However I have this problem.

    I noticed in your Demo Scene and video that "Use Physics 2D" is not ticked and it seems to work well, however when i try to replicate it, my jellysprite simply ignore the platform/box collider and went straight down (to endless). When I enable the "Use Physics 2D", it works, but it doesn't seems to be "squishy" or "jelly" - very static.

    I'm currently using Unity 5.2.0 Pro version. (I see that the asset have been submitted for 5.2.1 - I'm installing it now to try).

    I also noticed that you have the layer "JellySprite". Do i have to create that myself?


    EDIT: Updated to 5.2.1, works fine when I enable the "Use Physics". (But i still have no idea how the demo scene works without the "Use Physics" enabled)
     
    Last edited: Dec 1, 2015
  5. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey - the demo scene uses the 3D physics system - the walls/floors are all made of 3D colliders so the Jelly Sprites need to use 3D colliders too. If you switch it to 2D mode (using the flag in the inspector) then you'll need to replace all the colliders with 2D equivalents or else they'll just fall right through them. You've reminded me that I should really make 2D the default setting (the asset came out when the 2D Unity stuff was very new and still a bit flaky - I'm fairly sure pretty much everyone uses it for sprite based games now though).

    I don't think the Jelly Sprite layer is strictly needed - its just useful if you want to eg. disable collisions between Jelly Sprites. Unity should just stick the object into the default layer if you copy a Jelly Sprite from the demo scene into a different project that doesn't have that layer.
     
  6. weichendigital

    weichendigital

    Joined:
    Oct 13, 2015
    Posts:
    4
    Thanks. Another question. I notice the jelly sprite gravity is a little bug, I'm trying to make the jelly jump (quicker) but using timeScale is a bad choice for building into mobile (cause ultra FPS Spike) when I set the timeScale to 3.

    So my solution is to increase the gravity and the add force (only when it jumps). When it lands it will reset to 1. But the problem i'm facing is that when I set the gravity via script, editor does reflect it correctly, but the gravity is not applied (sometimes). How I notice this is when the gravity is in effect, the ball would look (extremely squashed), but it doesn't - yet the gravity in editor has already reflected the correct value in script.

    I set it like this

    JellySprite jellyPlayer;

    jellyPlayer.m_GravityScale = 10;
     
  7. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey,

    Ah - okay, the problem here is that you're setting the gravity scale on the parent Jelly Sprite object, but that value isn't actually getting passed down to the physics objects. Try this instead:

    Code (csharp):
    1. jellyPlayer.m_GravityScale = gravityScale;
    2.  
    3. foreach (JellySprite.ReferencePoint referencePoint in jellyPlayer.ReferencePoints)
    4. {
    5.    if (!referencePoint.IsDummy)
    6.    {
    7.       if (referencePoint.Body2D)
    8.       {
    9.          referencePoint.Body2D.gravityScale = jellyPlayer.m_GravityScale;
    10.       }
    11.    }
    12. }
     
  8. weichendigital

    weichendigital

    Joined:
    Oct 13, 2015
    Posts:
    4
    Thanks, it works.
     
  9. biscito

    biscito

    Joined:
    Apr 3, 2013
    Posts:
    79
    is it possible to mixe, jelly mesh & svg ?
     
  10. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    SVG as in the vector graphic format? Assuming the importer that you're using just converts it to a standard Unity mesh then yep - it should work fine.
     
    biscito likes this.
  11. biscito

    biscito

    Joined:
    Apr 3, 2013
    Posts:
    79
  12. DiNoGames

    DiNoGames

    Joined:
    Feb 5, 2015
    Posts:
    14
    Hi,
    bought the asset yesterday and have a question right away.
    How would you setup a JellySprite in a way that for example it is an always bouncing ball.
    I have an edge which acts as the floor and the ball should just bounce off of it. If I use a Default circle collider I just have to set bouncyness to 1.0 and it does exactly what I want. How do I do this with a JellySprite?

    Greetings and thanks,
    Dirk
     
  13. lordhamburger

    lordhamburger

    Joined:
    Jul 24, 2014
    Posts:
    39
    You can add a material to the jelly sprite and set the bounciness of the material.
     
  14. lordhamburger

    lordhamburger

    Joined:
    Jul 24, 2014
    Posts:
    39
    Hey how can I add force to the jelly sprite in an arc? I know it uses multiple rigidbodies so the code I was going to use to have the character jump in an arc doesn't seem to work with jelly sprites.
     
  15. Etaat

    Etaat

    Joined:
    Jan 24, 2015
    Posts:
    2
    hi mrsquare
    could you please help me about prevent this type
    Untitled.png


    i have a player that come down whit gravity by some platforms that is coming up ...
    and actually the game object like Ghost pass through platforms collider ...
    2.png
    thanks
     
    Last edited: Jan 29, 2016
  16. DiNoGames

    DiNoGames

    Joined:
    Feb 5, 2015
    Posts:
    14
    Seems like another asset lost its support :(
     
  17. iwaszek12

    iwaszek12

    Joined:
    Feb 13, 2016
    Posts:
    1
  18. naveen_pambi

    naveen_pambi

    Joined:
    Jan 21, 2014
    Posts:
    9
    Hi mrsquare
    I'm implementing a tyre with jelly sprite, it seems like bouncy all the time, not resting at all, I tried increasing Spring Damping and Spring Stiffness but didn't help. How to stop bouncyness?
    And we need these tyre jelly sprites stack one over the other, here also they are not resting at all. Please help on this.
     
    Last edited: Apr 5, 2016
  19. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Eep, sorry everyone. I usually get emails notifying me of updates to this thread, not sure why I didn't get any for those last few replies (I did for naveen's, weirdly). If any of you guys from back in Jan/Feb are still having issues then please get in touch (and apologies for not getting back to you!)

    FWIW, if you can't get hold of me on here then please feel free to email (email address is in the asset readme file) as I'll definitely get that :)
     
    Last edited: Apr 6, 2016
  20. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey - tyres are notoriously difficult to get right (especially if you want them to appear realistic rather than cartoon-y). Mass can also play a big part in the stability of the bodies so its worth playing with that, as can the size of the bodies (scaling the colliders down generally makes things worse). If you haven't already. The 'Attach Neighbours' option might also be worth a shot - that'll add some additional springs to make the overall shape more rigid.
     
  21. MarkOakley1975

    MarkOakley1975

    Joined:
    Sep 11, 2015
    Posts:
    14
    Hi there,
    Recently bought Jelly Sprites and so far really impressed. I'm looking to do something along the lines of the above post (move/animated the jelly sprite and have it respond accordingly) but when I tried this script I got the following errors...

    Assets/JellySprites/Scripts/JellySpriteAnimator.cs(15,46): error CS1525: Unexpected symbol `spriteRenderer'

    Assets/JellySprites/Scripts/JellySpriteAnimator.cs(26,9): error CS8025: Parsing error


    Any thoughts on how I could solve this?

    Thanks
    Mark
     
  22. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hi Mark - sorry, away on holiday just now so can't test this myself but this looks like it might just be a compile error with this line:

    if(jellySprite spriteRenderer)

    It should be:

    if(jellySprite && spriteRenderer)

    Sorry - my bad, probably just a typo :)
     
  23. MarkOakley1975

    MarkOakley1975

    Joined:
    Sep 11, 2015
    Posts:
    14
    Thanks man, worked like a charm! Loving the asset. Hope you have a top holiday!

    Mark
     
    mrsquare likes this.
  24. Cobra98

    Cobra98

    Joined:
    Nov 23, 2013
    Posts:
    1
    Possible bug: Mesh Filter gets set to none on prefabs.

    What happens is when I load a scene that has Jelly Sprites in it that are created from a prefab, they all disappear, because the Mesh Filter is "Missing (mesh)".

    Here is how to recreate the bug
    #1 Create a new Jelly Sprite: GameObject->Create Other->Jelly Sprite->Unity Jelly Sprite
    #2 Assign any sprite to it
    #3 Make it a prefab by dragging it to the Project Window
    #4 Make a new instance of the prefab by dragging the prefab to the Hierarchy Window
    #5 The new instance will be missing a Mesh Filter

    This only happens in the editor, in play mode, a JellySprite Mesh is created.

    My workaround is to select the prefab, then change the sprite to a random one, then back to the original one.
     
  25. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey - thanks for this, I'll take a look. The mesh should be dynamically created when the Jelly Sprite is created, I'm guessing that this is just a quirk of how Unity initialises a new object vs. an instance of a prefab.

    As you've found - if you just modify the Jelly Sprite in some way (eg. change the mesh vertex density) then that'll force it to regenerate the mesh and it'll become visible.
     
  26. Apfelbeck

    Apfelbeck

    Joined:
    Oct 25, 2015
    Posts:
    5
    How does this scale to large number of physics bodies? My game peaks at about 100 active bodies at a time and I want it to run on a mid-spec phone, like an iPhone 5S if possible.

    I'm want to move this old project from XNA to Unity3D. It looks like I can save myself some time by using Jelly Spriter instead of porting my hand-rolled soft body physics.
     
  27. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Its hard to say exactly, but the code only uses standard physics bodies so you can roughly simulate that by just spawning a bunch of regular physics bodies and see how that performs. Each Jelly Sprite is going to contain around 5 physics bodies + colliders + joints (depending on the layout config you use), so if you're wanting 100 Jelly Sprites then you'd need about 500 physics objects active in the scene. I'd hazard a guess and say that might be too much for a 5S, unfortunately.
     
  28. Apfelbeck

    Apfelbeck

    Joined:
    Oct 25, 2015
    Posts:
    5
    Ok thanks for the input. I'll roll up a test harness like that and measure the results.
     
  29. adorzhang

    adorzhang

    Joined:
    Aug 23, 2016
    Posts:
    4
    Hi, i'm newbie
    I try to make a game that as the same link : http://madfatcat.com/game/2563/Blob_Thrower.html. With JellySprite tool, how to make blobs combine with ? I tried but see be don't natually. Please give me any idea ?

    Thanks !
     
    theANMATOR2b likes this.
  30. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hi :)

    Unfortunately there isn't a way to combine multiple Jelly Sprites, so you'd probably have to cheat a little bit to get this effect. If it were me, I'd probably disable the collisions between the two Jelly Sprite objects, and then apply a force to attract both of them together (like a magnet). Once they are in the same place, shrink one of them down and scale the other one up to make it look like they're merging into one. Once the smaller one is below a given scale, you can delete it, at which point you would just be left with one blob.
     
  31. adorzhang

    adorzhang

    Joined:
    Aug 23, 2016
    Posts:
    4
    Ok, Thanks for support!
     
  32. saruzaru

    saruzaru

    Joined:
    Jun 8, 2013
    Posts:
    18
    Hi :)

    Is there any way i could make the generated meshes be compatible with the new motion blur features that came out with 5.4 ?
    I'm using https://github.com/keijiro/KinoMotion to enable this, but the jelly meshes are not seen by it.
     
  33. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Interesting - wasn't aware of that feature, I'll take a look. Might be something shader-related maybe...

    *Edit*

    Seems to work fine for me... You're attaching the 'Motion' script to the camera, not to the Jelly Sprite object, right?
     
    Last edited: Sep 8, 2016
    theANMATOR2b likes this.
  34. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    64
    Does anybody know if it also works with the Corgi 2 / 2.5D engine?
     
  35. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey - I've not tried Corgi myself, but unless it uses any custom physics behaviour then I imagine it'll be compatible with Jelly Sprites. You might need to modify some of their character interaction scripts if you're applying Jelly Sprite behaviour to a player character, but the basic physics body movement -> wobble side of things should work fine.
     
  36. adorzhang

    adorzhang

    Joined:
    Aug 23, 2016
    Posts:
    4
    Hi,
    I tried attach jellysprite to gameobject and move it by gameobject but i can't. Do you have solution for this ?
    Thanks,
     
  37. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hi - in order to move the Jelly Sprite you need to move the Jelly Sprite physics bodies, and the gameobject will follow (look in your scene hierarchy while the game is running and you'll see an object called 'XXX Reference Points', where XXX is the name of your gameobject - these are the bodies that need to be moved).

    The best way to do this is to apply physics forces, eg.

    Code (csharp):
    1. GetComponent<JellySprite>().AddForce(force)
    By using forces, you'll ensure that the physics bodies move around naturally, which results in a nice bouncy Jelly Sprite.

    You can also set the position explicitly if you really need to, eg.

    Code (csharp):
    1. GetComponent<JellySprite>().SetPosition(newPosition)
     
  38. adorzhang

    adorzhang

    Joined:
    Aug 23, 2016
    Posts:
    4
    Hi, Thank for your solutions. I tried but still can't solve my case. In my case, i want to attach jellysprite to a rope. This mean jellysprite just attach to a position, just can move by collision others with. In this case, do you have solution ?
    Thanks !
     
    Last edited: Oct 6, 2016
  39. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey - would you be able to send me a copy of your project? If you just upload it somewhere (eg. dropbox) and then PM a link, I'd be happy to take a look :)
     
  40. LionFische

    LionFische

    Joined:
    Oct 16, 2015
    Posts:
    103
    Rotating a Jelly Sprite.

    Hi, I have a function that I use to apply force to a JellySprite when I swipe it. Force is applying correctly. I would also like to be able to add rotation, but have been having difficulty with this.

    I'd appreciate advice on the matter.

    The following is the function. I'm not sure if I am addressing the right component, the JellySprite or the Transform when I use GetComponent. Either way there is no effect.

    Code (CSharp):
    1.    
    2.  
    3. public void ApplyForce()
    4.     {
    5.         this.gameObject.GetComponent<JellySprite> ().AddForce (Vector2.up * force);
    6.  
    7.         this.gameObject.GetComponent<JellySprite> ().transform.Rotate (0, Time.deltaTime, 0);
    8.  
    9.         Debug.Log ("Apply Force");
    10.     }
    11.  
    12.  
    Thanks in advance for any help.

    2h.
     
  41. LionFische

    LionFische

    Joined:
    Oct 16, 2015
    Posts:
    103
    I'm started to suspect that a rotation begins but resets to 0.

    2h.
     
  42. LionFische

    LionFische

    Joined:
    Oct 16, 2015
    Posts:
    103
    I have two separate functions now. One to add force, one for rotation. Both are calling according to Debug, but effect from rotation not obvious.

    Code (CSharp):
    1.    
    2.  
    3. public void ApplyForce()
    4.     {
    5.         this.gameObject.GetComponent<JellySprite> ().AddForce (Vector2.up * force);
    6.  
    7.         Debug.Log ("Apply Force");
    8.     }
    9.  
    10.     public void ApplyRotation()
    11.     {
    12.         this.gameObject.GetComponent<JellySprite> ().transform.Rotate (Vector3.right * -90);
    13.  
    14.         Debug.Log ("Apply Rotation");
    15.     }
    16.  
    17.  
    2h.
     
  43. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    For anyone else wondering the same thing - don't position/rotate the Jelly Sprite transform directly, you always want to interact with the physics bodies, and their positions will then map back to the position + deformation of the sprite. There are several built in functions that you can use to do this, eg.

    Code (csharp):
    1. GetComponent<JellySprite>().AddForce
    2. GetComponent<JellySprite>().Rotate
     
  44. shidec

    shidec

    Joined:
    Jul 3, 2013
    Posts:
    1
    [​IMG]

    I want to create and object that act like a spring, the bottom of the spring is fixed, the top one can be moved by give it force (or manually).
    Is it possible to do?

    I have tried to explore the example, but none can do it.
    I think it will need squence ref point, so each ref point not connected to the central.
     
  45. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hi Shidec - sorry for not getting back to you sooner via email, have been away over the Xmas break.

    That configuration isn't supported by default but it should be reasonably easy to add. Let me take a look and I'll get back to you shortly.
     
  46. demondazza

    demondazza

    Joined:
    Mar 11, 2015
    Posts:
    2
    Hey,

    Great asset! Just purchased and was wondering if it is possible to use a jelly sprites as a projectile? I have a prototype game in the works that currently has a character that launches projectiles in the direction of a swipe. Currently I use 2d circle colliders as the projectiles which work well but I wanted to use a jelly sprite instead. However, when I use a jelly sprite, the physics make the sprite fall vertically and doesn't allow the swipe to direct it's projection. My swipe controller allows me to set any game object with a 2d rigid body to be the projectile. If I add a 2drigidbody to the jelly sprite, it still only drops vertically. Is it possible to use jelly sprites as a projectile?

    Thanks
     
  47. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey - yep, that should certainly be possible.

    If you want to interact with a Jelly Sprite (eg. by applying forces to it when you swipe, as per your example), you need to apply forces to the Jelly Sprite's reference points, These are the rigid bodies that are dynamically created at runtime in order to control the position and deformation of the Jelly Sprite. If you look in the scene hierarchy view when the game is running, you should see them under a parent called 'X Reference Points' (where X is the name of your object)

    I suspect that your swipe code is doing something like:

    Code (csharp):
    1. this.rigidbody2D.AddForce(force);
    If you want to apply force to a Jelly Sprite instead, you need do this:

    Code (csharp):
    1. GetComponent<JellySprite>().AddForce(force)
    that function will automatically grab the central reference point from the Jelly Sprite and apply a force to it, in much the same way as you would apply a force to a regular rigid body.

    (oh, and I wouldn't recommend adding a rigid body to the Jelly Sprite object itself, it'll generally just interfere with the reference points and cause all sorts of weirdness)
     
  48. demondazza

    demondazza

    Joined:
    Mar 11, 2015
    Posts:
    2
    Hey mrsquare,

    Many thanks for the reply. I manged to get it working with your recommendations. Initially I had a null reference error that was being thrown when instantiating the new projectile when using the Jelly sprite. I fixed this by adding a coroutine that applied the force a frame later which solved the problem. Works great! Thanks again.
     
    mrsquare likes this.
  49. io-games

    io-games

    Joined:
    Jun 2, 2016
    Posts:
    13
    Help!!!
    It does not work at all in build (exe and android apk)

    I/Unity ( 9791): NullReferenceException: Object reference not set to an instan
    ce of an object
    I/Unity ( 9791): at JellySprite.Update () [0x0000b] in D:\Unity Projects\Red
    Ball\Assets\JellySprites\Scripts\JellySprite.cs:2053

    Please, help
     
  50. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    241
    Hey,

    That doesn't look like it'll be anything Android specific - I suspect you'll be seeing the same error in the editor. If you look in the 'Console' output window, there should be an error message in there.

    Going by the line number (2053), its throwing an exception inside the Scale() function - are you calling that anywhere in your code? Are you perhaps trying to do it before the Jelly Sprite has had a chance to initialise? (this is done in the Start function, so you'd need to make sure it was after that).

    If you can't figure it out, I'd by happy to take a look - just upload your project somewhere and send me a link via PM.