Search Unity

  1. We want you to join us at GDC this year! Take a peek at all of the events we will be hosting during the week of GDC.
    Dismiss Notice
  2. Tell us about your experience here and you’ll get early access to the 2018 Game Studios report + more goodies.
    Dismiss Notice
  3. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  5. 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

Jelly Sprites - Soft body sprite physics system

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

  1. io-games

    io-games

    Joined:
    Jun 2, 2016
    Posts:
    13
    Thanks! Updated to 5.5 and the problem gone
     
  2. dergachoff

    dergachoff

    Joined:
    Aug 7, 2015
    Posts:
    4
    Hi, @mrsquare!

    You've made a really great asset! But I've stumbled upon an issue. When I set JellySprite mode to Grid through inspector, I get no gizmos in the scene and the following error in the console:

    NullReferenceException: Object reference not set to an instance of an object
    JellySprite.OnDrawGizmosSelected () (at Assets/Plugins/JellySprites/Scripts/JellySprite.cs:2406)
    UnityEditor.DockArea:OnGUI()

    I'm using Unity 5.5.1.f1
    Any ideas how to fix it?

    Thanks!
     
  3. dergachoff

    dergachoff

    Joined:
    Aug 7, 2015
    Posts:
    4
    Also: any way to add a 2d joint (like a hinge joint) to the central (or any other) body?
     
  4. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    244
    Hey - sorry for the slow reply. Hm, that's odd - I'm on a slightly earlier version, but not seeing that. Let me upgrade to 5.5.1.f1 and give it a try.

    Re. adding a joint to the Jelly Sprite - you'd have to do that programatically due to the reference points being created at runtime, but you'd just need a bit of code like this:

    Code (csharp):
    1.  HingeJoint2D joint = GetComponent<JellySprite>().CentralPoint.GameObject.AddComponent<HingeJoint2D>();
    Or alternatively, set up your hinge joint in the inspector and then just attach it to the central Jelly Sprite body at runtime.
     
  5. smasters654

    smasters654

    Joined:
    Dec 20, 2013
    Posts:
    29
    Hi @mrsquare

    I sent you an email about you jelly mesh asset regarding 2 materials on an mesh a bit ago but I haven't heard from you. I would have posted this in the jelly mesh forum post but it seemed pretty dead on there sorry. Please let me know how to fix this issue? Thanks!
     
  6. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    36
    Hi @mrsquare

    Is it possible for you to clarify how to add distance joints or hinge joints etc. to jelly sprites? It would be great. Thanks.
     
    Last edited: Nov 20, 2017
  7. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    244
    Hey - sorry for the slow reply.

    So, from a script attached to the Jelly Sprite, you can access the Jelly Sprite reference points like this:

    Code (csharp):
    1. JellySprite jellySprite = GetComponent<JellySprite>().ReferencePoints[x];
    Reference points are the physics objects that control the Jelly Sprite behaviour - you'll have a different number depending on what configuration you're using. The one at index 0 is always the central reference point, and the others will be attached to that.

    The reference point itself is just a little data structure that contains a gameobject and some other info. So to add a distance joint, you just add a DistanceJoint2D component to the reference point gameobject as you would with any other gameobject:

    Code (csharp):
    1. // Get the Jelly Sprite component
    2. JellySprite jellySprite = GetComponent<JellySprite>();
    3.  
    4. // Get the reference point gameobject (pass in an index from 0 -> jellySprite.ReferencePoints.Count)
    5. GameObject jellySpriteReferencePointObject = jellySprite.ReferencePoints[0].GameObject;
    6.  
    7. // Add a new distance joint
    8. DistanceJoint2D distanceJoint = jellySpriteReferencePointObject.AddComponent<DistanceJoint2D>();
    9.  
    10. // Configure the distance joint
    11. distanceJoint.connectedBody = someOtherRigidBody;
    12. ...
    13.  
     
    kapopixel likes this.
  8. Goodyearpimp

    Goodyearpimp

    Joined:
    Jun 5, 2014
    Posts:
    3
    I've purchased both JellyMesh & JellySprite recently (great work by the way MrSquare).


    I was hopeful that I could use this in tandem with SVG Importer from the Asset Store (Jarolic's). I am unable to use either JellyMesh or JellySprite with the Unity MeshRenders or MeshFilters generated automatically when importing SVGs through his asset. Any help???
     
  9. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    244
    Hey - sorry, I'm not familiar with that asset (and sadly is a bit pricey for me to give it a test!). If you could send me an example project containing some meshes you've used it to generate, then I might be able to diagnose the issue.
     
  10. jooyeon0103

    jooyeon0103

    Joined:
    Sep 26, 2017
    Posts:
    1
    Hello,

    I instatiated many Jelly Sprite from PinkBlob in demo scene.
    I make prefabs, and instantiate from code.

    But some PinkBlob instance have been teared. I attached a screen shot and marked red box.
    How can I avoid this sprite error?

    Thank you.
     

    Attached Files:

  11. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    244
    Hey - sorry for the slow reply.

    Its hard to tell without seeing it in motion, but judging by the screenshot it looks like some of the bodies are getting stuck on something and/or getting a very large force applied to them, which is causing them to move far away from their default formation. Assuming that you don't have any invisible platforms or anything in your scene that they're getting stuck on, you could try increasing the collider radius, or maybe using the 'Attach Neighbors' options, both of which should help them keep their shape a bit better.

    Having said that, that is a very large number of physics bodies + springs that you have in a confined space, so it could just be the physics engine freaking out! Might be worth reducing the number of Jelly Sprites and/or bodies per Jelly Sprite, if that is an option.
     
  12. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    213
    Will the Jelly Sprites jiggle by only moving them around (dragging) without collision? I want the jiggle effect this system has, but never having to collide with any terrain or objects.
     
  13. HyunMok_Moon

    HyunMok_Moon

    Joined:
    Oct 14, 2016
    Posts:
    2
    Hello mrsquare,

    I want to change tint color in UnityJellySprite component.
    I changed m_Color value in runtime.

    from JellySprite.cs
    // Tint color
    public Color m_Color = Color.white;

    from my code,
    transform.GetComponent<UnityJellySprite>().m_Color = new Color(1f, 1f, 1f, 0.5f);

    I can see "Tint Color" value is applied in Inspector window.
    But sprite image is not change in Game view.
    When I change from Inspector, Tint Color in UnityJellySprite component I can see in Game view.

    I changed Alpha value.

    renderer.sharedMaterial.SetColor("_TintColor", colorValue)
    it work neighter.

    Thank you.


    I resolved.
    Sprites/Default shader, use _Color property as Color: Tint. so I changed _TintColor -> _Color
    it works!!
     
    Last edited: Nov 7, 2017
    mrsquare likes this.
  14. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    244
    Hey - yeah, you can turn off the collision on the Jelly Sprite colliders, that shouldn't be a problem (or else just put them into a layer that has no collision).
     
  15. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    36
    Hello @mrsquare ,

    Have you tested mobile performance of Jelly Sprites lately ? I saw your answer about performance on iPhone4 but it is from May 2014.

    I am using one Jelly Sprite character containing 18 custom bodies with default vertex density settings (10) and wondering if it is OK for devices like iphone 6s and above. I think 18 active bodies mean 36 joints but have no idea what this means in terms of mobile performance. Any idea or experience you can share?

    Thanks a lot.
     
  16. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    244
    Hey - yeah, I reckon you'll be fine on a 6s. That's not a huge amount of physics bodies (probably about the same as the demo scene included with the package), and even though the 6S is a few years old, it still has a pretty beefy CPU. Device-wise, I've tested on an iPhone 4S, Nexus 7, and a Galaxy S7 - the S7 is probably the closest match for the 6s, and I can't imagine that having any issue running the demo scene at 60fps+.
     
    kapopixel likes this.
  17. gfaraj

    gfaraj

    Joined:
    Jul 11, 2016
    Posts:
    23
    Hi @mrsquare

    I purchased your asset and it's been pretty great so far. Here's a question for you though. I'm trying to use this in a simple platform game. For the platform I'm using the built-in Platform Effector 2D so that the player can jump through platforms.

    The problem here is that since the jelly has several colliders, when jumping up, it's possible for the character to get stuck in the platform -- only the upper colliders of the jelly passed through the effector, but when it falls back down, those colliders will now collide with the platform.

    Do you have any suggestions on how to make this asset work with platform effectors?
     
  18. chanfui

    chanfui

    Joined:
    May 2, 2017
    Posts:
    1
    I use OnJellyCollisionEnter2D and also the Unity's OnTriggerEnter2D / OnCOllisionEnter2D,

    Because inside the Jelly has more than one collider, causing OnTriggerEnter2D / OnCollisionEnter2D, and also OnJellyCollisionEnter2D being called multiple times.

    How can I make it as one collider to trigger the above collision/ trigger functions only once everytime when the sprite enter / exit the collider?

    Also,
    I use public bool IsGrounded(LayerMask groundLayer, int minGroundedBodies) function but it always return true.
    Is that a bug or I've understand it wrongly? So far I have only 8 colliders, but i put minGroundedBodies as 10 it still return me true.
     
  19. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    36
    Nice question indeed. I also want to know if there is a solution to this.
     
  20. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    36
    Hey @mrsquare,

    Is there a way to deform a mesh dependent to jellysprite's behaviors? So I can create a fake drop shadow. In other words, I am basically trying to copy behaviors of a jellysprite.

    (There is a post about how to animate a jellysprite by attaching jellysprite's sprite to another animated sprite. So basically I am trying to create vice versa behavior of this).

    Thank you.
     
  21. satyamparkhi

    satyamparkhi

    Joined:
    Jul 7, 2017
    Posts:
    2
    My sprite is not showing up and i am getting this error


    upload_2017-12-17_8-49-52.png

    upload_2017-12-17_8-50-19.png
     
  22. satyamparkhi

    satyamparkhi

    Joined:
    Jul 7, 2017
    Posts:
    2
    when i am adding sprite to the script its coming white and also some error

    upload_2017-12-17_10-29-32.png
    upload_2017-12-17_10-29-44.png
    upload_2017-12-17_10-29-53.png
    upload_2017-12-17_10-30-39.png
     
  23. Drinksarlot

    Drinksarlot

    Joined:
    Apr 27, 2017
    Posts:
    1
    Is there any way to make the jelly change shape in reaction to user input? Specifically I'm wanting it to act like a ball of slime - so if someone pushes on the right side of the jelly, then the right side will squeeze out. I can see how to apply a force but that doesn't seem to do what I'm after.
     
  24. smart-machines

    smart-machines

    Joined:
    Sep 25, 2017
    Posts:
    1
    Hello there and congratulations for this addon.
    I'm using the Jelly Stripes in 2D and I'm trying to get the bounds of the stripe drawn.
    I have seen that in the JellySprite.cs there is many times the value of width and height which are used to build or update vertices but they live only in the scope of some function.
    The curious thing is when I try to access it this value with

    JellySprite jellyBulle = Bulle.GetComponent<JellySprite>();
    Debug.Log(jellyBulle.m_SpriteScale);
    UnityJellySprite UJellyBulle = Bulle.GetComponent<UnityJellySprite>();
    Debug.Log(UJellyBulle.m_Sprite.bounds);

    Where Bulle is the JellyStripe GameObject
    I get the correct values and after that an exception about a null pointer reference : Object reference not set to an instance of an object.
    How it can possible ?
    a reference is giving a null pointer but with a correct value of the reference
     
  25. TobyKaos

    TobyKaos

    Joined:
    Mar 4, 2015
    Posts:
    149
    @Drinksarlot maybe try with Attach Neighbors on
    By settings this Z rotation is locked for ref points. If you want the slim rotate again you must set off programatically on Start.
    Set 20 num colliders at 0.1 size. And maybe increase vertex density...
     
  26. TobyKaos

    TobyKaos

    Joined:
    Mar 4, 2015
    Posts:
    149
    Hello @mrsquare
    a bug in transform parenting occured when you load a scene with a jellysprite and unload the active scene because ReferencePoints parent is created in active scene. To avoid this you should add in JellySprite::Start() at line 498:

    Code (CSharp):
    1. // fix parenting
    2.             if(transform.parent != null)
    3.                 m_ReferencePointParent.transform.parent = transform.parent;
    4.             else
    5.             {
    6.                 m_ReferencePointParent.transform.parent = transform;
    7.                 m_ReferencePointParent.transform.SetParent(null);
    8.             }
    Same for JellyMesh I think.


    Another suggesion is to add a ForwardMessage in JellyMeshReferencePoint.cs to use Custom SendMessage. (I have already suggest you for JellyMesh)

    Code (CSharp):
    1.  /// <summary>
    2.     /// Ajout perso pour forward un message lors d'une collision
    3.     /// </summary>
    4.     /// <param name="values"></param>
    5.     void ForwardMessage(object values)
    6.     {
    7.         if (ParentJellyMesh && SendCollisionMessages)
    8.         {
    9.             object[] obj = (object[])values;
    10.      
    11.             ParentJellyMesh.SendMessage((string)obj[0], obj[1], SendMessageOptions.DontRequireReceiver);
    12.         }
    13.     }
    This function help me in my hurt character logic.
     
    mrsquare likes this.
  27. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    244
    Hey - sorry for the lack of replies everyone, seems that my email notifications stopped working for some of my watched threads.

    The only explanation that I can think of here is that the null pointer reference isn't coming from this exact bit of code, but something running very soon afterwards. If you click on the error in the console, you should see the callstack, which will show you the exact file/line of code that is throwing the exception - eg.

    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. JellySprite.AddReferencePoint (Vector3 position, Single radius, Boolean lockRotation) (at Assets/JellySprites/Scripts/JellySprite.cs:921)
    3. JellySprite.CreateRigidBodiesCircle (Bounds spriteBounds) (at Assets/JellySprites/Scripts/JellySprite.cs:600)
    4. JellySprite.Start () (at Assets/JellySprites/Scripts/JellySprite.cs:451)
    Hopefully that will give some more clues.