Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 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. Mooshoo-Labs

    Mooshoo-Labs

    Joined:
    Aug 21, 2014
    Posts:
    14
    Hi @mrsquare

    I've been experiencing issues when trying to have more than one attach point on a jelly sprite. I took the demo scene, duplicated the eyes of PinkBlob and added them as an attach point. As soon as I press play, the second attach points gets set to null (which of course causes issues in the script). The behaviour stays the same no matter how many attach points I add. The first one acts normally while all others get set to null. I've check the scripts and am fairly certain that the issue isn't in the actual JellySprite script, which leads me to believe there is some weird behaviour happening with the custom editor and maybe my version of Unity. I'm currently on 4.6, using the Pro version. Could you let me know if you can replicate this issue?

    EDIT: it seems to be caused by prefabs. As long as I apply my changes to the parent prefab before playing, all is good. I'll just leave this here in case somebody faces the same issue.

    Thanks
     
    Last edited: Mar 25, 2015
    SkyboardSoftware likes this.
  2. gautsch

    gautsch

    Joined:
    Dec 22, 2012
    Posts:
    15
    Hey there, @mrsquare
    Really digging Jelly Sprites. I'm currently trying to use it with Playmaker and it's giving me a few issues.
    Playmaker requires an object to have a 2DRigidbody to add force to it. The problem with Jelly Sprites is that those rigidbodies aren't generated until I hit play. When I grab 'JellySprite Central Ref Point' and drop it into the AddForce GameObject slot, it applies force just as it should, but because it's only there at runtime, I can't wire it up before.
    I tried using the action posted in the Hutong Games forums but that's borked.
    Any tips?
     
    Last edited: Mar 27, 2015
  3. betaFlux

    betaFlux

    Joined:
    Jan 7, 2013
    Posts:
    12
    Hello, is it possible to make sprites only partially effected by Jelly physics (i.e. hat, hair)?
     
  4. SkyboardSoftware

    SkyboardSoftware

    Joined:
    Jul 20, 2013
    Posts:
    39
    excellent. .I was having the same issue.. I tried to add an object to my jelly and then in playmode the attachpoints reset to the prefab setting. took a few tries to discover the behavior. nice catch. ** hit apply after setting attachpoints" if object is a prefab. whoo hoo
     
  5. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    687
    Sorry if this has been asked/answered before but can Jelly Sprite be used to create a 2D buoyancy effect, side on simple water with sprites floating around on it and dropping into it?
     
    Last edited: May 9, 2015
  6. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey. People have used it to make Jelly 'platforms' in the past (so essentially a large wobbly Jelly Sprite that characters can jump on), which doesn't sound too dissimilar - check out the Jelly 'bridge' discussion on the first page of the thread and the video posted by user p6r.

    In general though, Jelly Sprites are best used on smaller character sized objects - you'd probably get a better effect from one of the dedicated 2D water systems that are on the asset store, eg.

    https://www.assetstore.unity3d.com/en/#!/content/8716
    https://www.assetstore.unity3d.com/en/#!/content/9149

    (I've not used them myself, but have implemented a very similar system in my own games)
     
  7. Didmon

    Didmon

    Joined:
    Feb 7, 2015
    Posts:
    2
    Hello, I bought your plugin. I created a clean project for android devices only with your plugin.I compiled your demo scene on Unity3d v5.0.1f.

    When running on a mobile device jelly (jelly sprites) do not move. I changed the settings and run applications on different versions of android 4.0+ and 5.0+. Nothing helped. Jelly is completely static and do not collide with other rigidbody objects (2d or 3d).
    Screenshot_2015-05-11-16-17-03.jpg

    In Unity Editor all works fine.

    What I supose to change to make your plugin work on android device?

    Thank you!
     
  8. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey,

    Sorry that you're having problems. If they're not moving at all (but work fine in the editor) that *usually* suggests that there is an error being thrown somewhere and the Jelly Sprite component is failing to initialize. Couple of questions:

    1) When you run the scene in the Unity Editor, are you seeing any errors/warnings in the 'Console' window?
    2) Have you modified anything in the code and/or demo scene, or is this exactly the same is if it had just been downloaded from the asset store?
     
  9. Didmon

    Didmon

    Joined:
    Feb 7, 2015
    Posts:
    2
    I have solved my probleb. I created new gameobject with JellySprite how you have shown in a lesson. New objects are working on an Android device. Objects from the demo scene is not working. Thank you for your wonderful plugin!
     
  10. frispgames

    frispgames

    Joined:
    Feb 24, 2015
    Posts:
    3
    hi @mrsquare, in my game I have an empty game object collider which acts a destroying collider. Anything that hits it gets destroyed to clean up game objects that have gone off screen.

    voidOnTriggerEnter2D (Collider2Dother) {
    Destroy (other.gameObject);
    }

    I noticed this does not work for the Jelly sprite game objects in my game, they do not get deleted by this code. How would I go about removing jelly sprite game objects as they collide with this "destroying collider".

    Also the following error occurs: The object of type transform has been destroyed but you are still trying to access it. This occurs on line 2129 of JellySprite.cs.
     
    Last edited: May 12, 2015
  11. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - try this instead:
    Code (csharp):
    1. void OnTriggerEnter2D(Collider2D other)
    2. {
    3.     JellySpriteReferencePoint referencePoint = other.GetComponent<JellySpriteReferencePoint>();
    4.      
    5.     if(referencePoint)
    6.     {
    7.         Destroy(referencePoint.ParentJellySprite);
    8.     }
    9.     else
    10.     {
    11.         Destroy (other.gameObject);
    12.     }      
    13. }
    It is presumably one of the Jelly Sprite reference points that is colliding with the trigger, not the Jelly Sprite gameobject itself. You just need to query the Jelly Sprite gameobject from the reference point and destroy that instead.
     
  12. frispgames

    frispgames

    Joined:
    Feb 24, 2015
    Posts:
    3
    @mrsquare thanks heaps it works :). You are exactly right I was printing out the collider and it was the reference points getting printed and removed on collision.

    One more thing, regarding lighting in 2D, is there something special I need to do. I have created a sprites diffuse material and added it to the the mesh renderer material section on the jelly sprite but the jelly sprite is still not getting affected by light from a point light. All my normal other game objects are lit by the point light using this material.
     
  13. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Mm, I'm not 100% sure, sorry - I generally just work with regular unlit sprites so I've not had much experience with the Unity lighting system. Having said that, a Jelly Sprite is just a basic 2D plane so I doubt that there is anything inherent in the Jelly Sprite code that would be breaking things. What are the other gameobjects in the scene? Have you managed to get lighting to work on a non Jelly Sprite sprite (if you get my meaning)?
     
  14. frispgames

    frispgames

    Joined:
    Feb 24, 2015
    Posts:
    3
    no problem, I will continue to try get it to work. Have you ever tried lighting a jelly sprite yourself? I just have basic 2d sprites with a sprite diffuse material applied to them and they seem to be lighting just fine by a point light.
     
  15. tnbao91

    tnbao91

    Joined:
    Sep 5, 2013
    Posts:
    41
    Your plugin can do like this ?



    :)
     
  16. shmulik.pangolin

    shmulik.pangolin

    Joined:
    Nov 11, 2014
    Posts:
    12
    @mrsquare ,
    I'm new to your plugin (just bought it today).
    I can't figure out a good way to drag jellysprites (by touch or mouse) or to move them around..can you give me a tip about it?
    Thanks
     
  17. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - sure, that should be pretty easy to do. I'll write a script for you and post it up here.

    Hey - sort of! That video looks like it is using the Wallaber/JelloPhysics engine, which is very cool but very expensive. You'd have a very hard time running it at a decent framerate on mobile devices with more than a few objects. Jelly Sprites can provide a similar effect - it is much faster but also not as accurate.

    There was a version of JelloPhysics made for Unity but it is no longer supported by the author - if you search for 'mukow Jello Physics' then you should be able to find it (he released the source code for free after removing it from the asset store). Its quite complicated to use (and slow) but you might get some use out of it depending on your coding skills :)
     
  18. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Here you go - stick this in a component called JellyMouseControl, attach that component to the Jelly Sprite, and it'll try to move the Jelly Sprite to the mouse coordinates each frame.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [RequireComponent(typeof(JellySprite))]
    5. public class JellyMouseControl : MonoBehaviour
    6. {
    7.     JellySprite jellySprite;
    8.  
    9.     void Start ()
    10.     {
    11.        // Cache the jelly sprite component (saves having to find it each frame)
    12.        jellySprite = GetComponent<JellySprite>();[/INDENT]
    13.    }
    14.  
    15.    void Update ()
    16.    {
    17.       // Get the mouse position in world coords
    18.  
    19.       // Keep the z position the same
    20.       mousePosition.z = jellySprite.CentralPoint.GameObject.transform.position.z;
    21.  
    22.       // Move the jelly sprite to the mouse position (separate code for 2D/3D modes)
    23.       if(jellySprite.CentralPoint.Body2D)
    24.       {
    25.          jellySprite.CentralPoint.Body2D.MovePosition(mousePosition);
    26.       }
    27.       else if(jellySprite.CentralPoint.Body3D)
    28.       {
    29.          jellySprite.CentralPoint.Body3D.MovePosition(mousePosition);
    30.       }
    31.    }
    32. }
     
  19. JaMeZwHiTe

    JaMeZwHiTe

    Joined:
    Jun 8, 2012
    Posts:
    85
    Hi there,

    Bought your plugin a while ago but only just got round to using it. Every time I create a new Jelly Sprite and hit File > Save, I get this message in the console, every time:

    "Cleaning up leaked objects in scene since no game object, component or manager is referencing them
    Material Player_Jelly has been leaked 1 times.
    Mesh JellySprite Mesh has been leaked 1 times."

    I'm using Unity 5.1. Otherwise, this plugin is fantastic!
     
  20. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey :) Just sent you a reply via email, but for anyone else wondering about this - check out this thread:

    http://answers.unity3d.com/questions/38960/cleaning-up-leaked-objects-in-scene-since-no-game.html

    Basically, it's harmless. It happens because Jelly Sprites is creating procedural data, Unity is just saying that it has done some optimisations and cleaned them stuff that isn't being referenced any more. It's an editor only thing and nothing to worry about - won't cause any problems either in the Editor in a standalone build.
     
    theANMATOR2b likes this.
  21. ATesija

    ATesija

    Joined:
    Jun 17, 2015
    Posts:
    1
    Hey mrsquare I bought and started using JellySprite today and love it! One thing I'm trying to do is to create an amoeba that stretches when you are moving. I've attached a picture to give you a visual of the effect I'm looking for. It seems that the jelly physics only apply when colliding with objects so I'm wondering if there is a way to pull it off. I've tried making the collider radii smaller so that there is space between them, and I've also tried only applying force to the center point of the jelly sprite. The latter allows the center to move within the amoeba but doesn't deform the outside. Any ideas you have would be awesome! Untitled.png
     
  22. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - sorry for the delayed reply!

    Interesting question. Have you tried applying a 'primary' force to the central body, and then applying a secondary (lesser) force in the opposite direction to the remaining bodies? Something like:

    Code (csharp):
    1. Vector2 force = XXX;
    2. float secondaryForceScale = 0.25f;
    3.      
    4. JellySprite jellySprite = GetComponent<JellySprite>();
    5.      
    6. for(int refPointIndex = 0; refPointIndex < jellySprite.ReferencePoints.Count; refPointIndex++)
    7. {
    8.     if(refPointIndex == 0)
    9.     {
    10.       // Central body, apply the full force
    11.       jellySprite.ReferencePoints[refPointIndex].Body2D.AddForce(force);
    12.    }
    13.    else
    14.    {
    15.       // Edge body, apply a fraction of the full force in the opposite direction
    16.       jellySprite.ReferencePoints[refPointIndex].Body2D.AddForce(-force * secondaryForceScale);
    17.    }          
    18. }
     
  23. wolodo

    wolodo

    Joined:
    Nov 22, 2012
    Posts:
    55
    Hi!

    Is there a way to remove attach points during runtime? I have tried every possible combination of modifiing m_AttachPoints, m_NumAttachPoints and calling ResizeAttachPoints() but it keeps throwing errors.

    Thanks in advance.
     
  24. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Have replied in private, will include the fix in the next update as its a bit long to post here. For anyone else having this problem, gimme a shout and I'll send you the relevant code :)
     
  25. Lacuna-Corp

    Lacuna-Corp

    Joined:
    Feb 15, 2015
    Posts:
    61
    Hi,

    I'm really loving the physics of Jelly Sprites so far, but I'm having some issues. Hopefully you'll be able to help me out here, as I really want to get the asset working in my project.

    If you haven't heard of the game Agar.io, please check it out (http://www.agar.io). I'm building a game similar to that, and I'm using Jelly Sprites for the physics. My issue is that when I try to use my controller, the sprite doesn't move. And I can't set it as a child to my existing player object, because it doesn't move for some reason. Basically, I want to have a blob which I can move around, but it just won't move, or when it does (disable 2D physics mode), it just falls, even when there's no gravity.
     
  26. Lacuna-Corp

    Lacuna-Corp

    Joined:
    Feb 15, 2015
    Posts:
    61
    My last reply, scratch that. I managed to fix it by just setting the transform of the jelly sprite to the transform of my player, I never realised that you couldn't just use it's transform, but you had to use JellySprite.SetPosition. I sorted out the dodgy jumping by turning up the spring tension as well.

    Just one thing- can I change the sprite's colour? I could do it with Unity's normal sprites using material.setcolor, but I couldn't find any related variables in the Unity Jelly Sprite script. Will I have to find a way to do this, or is there something simple which I'm missing?

    Apart from that, I'm loving the asset! The physics are looking great in my game, and I can't wait to see it all come together.
     
    Last edited: Jul 7, 2015
  27. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - sorry for the delayed reply! Glad you got your problem sorted :)

    With regards to setting the color, try:

    Code (csharp):
    1. GetComponent<JellySprite>().renderer.material.color = Color.red;
     
  28. danam

    danam

    Joined:
    Mar 30, 2015
    Posts:
    3
    Two questions: How do you used OnMouseDown with Jelly Sprites? You metioned something about a fix a year ago, has that been implemented? Also, I get the message: `UnityEngine.Rigidbody2D.fixedAngle' is obsolete: `The fixedAngle is no longer supported. Use constraints instead.' Is this related to Jelly Sprites?
     
  29. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey. Yeah, sorry that warning is from Jelly Sprites. Its a Unity 5-only thing - they've changed some of the physics variables and made a few of the old ones obsolete. I've just moved house so my dev PC has been packed away for the past week or so, but will try to get a new build submitted this evening. It shouldn't cause you any problems unless you're wanting to lock the rotation of a 2D Jelly Mesh (and even then, it might still work for the time being - the warning message is a bit unclear as to whether its just deprecated or fully redundant).

    What are you wanting to achieve with OnMouseDown? Did a quick search back through the thread but couldn't see it mentioned anywhere.
     
  30. bizarrejelly5

    bizarrejelly5

    Joined:
    Jun 30, 2015
    Posts:
    1
    Hey mrsquare.
    I have the same problem as Didmon, doesn't work when I run export to Android or Web Player. But that's not as important as my real problem.

    I'm making a project in 2D in Unity 5.0.0f4. I bring in JellySprite the same way you did in your video tutorial, using 2D physics, but setting gravity scale to 0. When I export it to Android and Web Player, the JellySprite would just fall down as if the gravity was set to something greater than 0. However it would still collide with any colliders it runs into so it doesn't fall infinitely.

    Everything works completely fine in the Editor and as an .exe. Been stuck on this problem for hours.
     
  31. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    I submitted a new build last night to fix the obsolete variable warnings in Unity 5, so that should be released to the asset store in a day or two.

    Not sure about that gravity issue, sorry - is it just Jelly Sprites that are exhibiting the problem, or do other physics objects do it too? If you build the webplayer version in Development Mode then that might give you some more info. It could be that some code somewhere is throwing an exception - this would cause Unity to cease execution of the current function which could leave things in a partially configured state. If you run in Development Mode then I think you get a little text box on-screen that'll display any warnings or errors from the log, so you should be able to verify if something is going wrong.
     
  32. aerandir92

    aerandir92

    Joined:
    Dec 4, 2014
    Posts:
    6
    Back again with another, possibly JellySprite problem, maybe.
    Building in WebGL results in the jellysprite object to appear distorted, sort of, it seems to only affect the main sprite of object.
    How it looks in WebGL, in both Chrome and FF:
    [​IMG]

    How it looks in any other build I have done (webplayer, windows, linux, mac, android):
    [​IMG]

    Worth noting, the same distortion is seen in the editor when on Android platform in earlier versions of Unity (4.6), but not, as mentioned, in an android build.
    Also, everything else seems to work fine visually except for this.
    I am using newest Unity as of today, 5.1.2f, and newest JellySprite avaiable, 1.30 (so have not received update you mentioned on friday)
     
    Last edited: Jul 20, 2015
  33. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - weird! I'll give it a try and see if I can reproduce the issue. Is it exclusive to that sprite, or does it happen in the demo scene too?
     
  34. aerandir92

    aerandir92

    Joined:
    Dec 4, 2014
    Posts:
    6
    Hm, not happening in the demo scene. Will look into that more tomorrow.
     
  35. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Worth double checking the debug output, if you can get access to that on a WebGL build. Something might have thrown an exception, which means that Unity will abort execution of that script. It prevents stuff from crashing, but can lead to weird behavior with things being left in an inconsistent state.
     
  36. aerandir92

    aerandir92

    Joined:
    Dec 4, 2014
    Posts:
    6
    Found the issue! Turning of mipmaps on the sprite fixed it.
     
  37. jbenjaminhollman

    jbenjaminhollman

    Joined:
    Jul 4, 2012
    Posts:
    2
    Hi there mrsquare, got a bit of a conundrum here.

    I'm trying to "pick up" a Jelly Sprite object by clicking on it using a raycast, then using that to access its JellySprite component. The problem is that a RaycastHit2D only stores the collider/rigidbody/transform of whatever you clicked on, which in this case isn't the Jelly Sprite itself, but one of its ReferencePoints. Since ReferencePoint is a nested class inside of the JellySprite component, I can't actually use it to access the whole JellySprite or the parent GameObject. Is there a workaround to this that I'm missing? I don't want to just create a separate Collider2D to catch the raycast, because that can be inaccurate when the sprite deforms.
     
  38. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - you should need to use the nested reference point class here. If you've got the collider belonging to the reference point, you can just do something like:

    Code (csharp):
    1.  
    2. Collider2D someCollider;
    3.  
    4. //Check to see if this is a JellySprite reference point
    5. JellySpriteReferencePoint referencePoint = someCollider.gameObject.GetComponent<JellySpriteReferencePoint>();
    6.  
    7. if(referencePoint)
    8. {
    9.     JellySprite parentJellySprite = referencePoint.ParentJellySprite;
    10.  
    11.     //Do stuff
    12. }
    13.  
    Basically, there is an internal JellySprite.ReferencePoint class, and a JellySpriteReferencePoint component that is added to each reference point - its the latter that you want to be using.
     
  39. jussikari

    jussikari

    Joined:
    Jul 9, 2015
    Posts:
    1
    Hi mrsquare, I purchased the asset and generally it is what I was after.

    The problem I have is that without "attach neighbours", I cannot get the physics exactly what I am after, but when I enable "attach neighbours", also the rotation will change to fixed. Otherwise physics looks what I want. Is this a bug? I have "lock rotation" not checked.
     
  40. Kinkku2

    Kinkku2

    Joined:
    Sep 29, 2014
    Posts:
    106
    Hey, I have a thing I'd like to implement and I'm having some trouble coming up with how to implement it. If it's possible to do with Jelly Sprites, I'd be super thankful if you could give a general gist on how to approach the problem. So, I have a 2D circle sprite that is a jelly sprite and I move with it in the game.

    I would like for some of the circle's reference points to sort of drag behind from the rear end when it moves. So the reference points in the opposite side to where the circle is moving would move slower than the front end and naturally catch up when the movement stops.

    How should I go about doing this? Thanks!
     
  41. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - sorry for the slow reply. Try opening up JellySprite.cs and navigating to the AddReferencePoint() function. On the first line, just change it to:

    Code (csharp):
    1.  
    2.     ReferencePoint AddReferencePoint(Vector3 position, float radius, bool lockRotation)
    3.     {
    4.         if(m_AttachNeighbors)
    5.         {
    6.             lockRotation = false;
    7.         }
    8.  
    9.     ...
    It is intended to lock the rotation on all the non-central bodies, but you're correct - it does seem to cause some weird behaviour when you've got AttachNeighbors ticked. I'll look into that - the above fix might be sufficient.
     
  42. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey - interesting question! It sounds like you'd need a new component to manage this behaviour for a start, which would detect which direction the player object was moving and apply the appropriate changes to the Jelly Sprite.

    You could maybe try relaxing the spring stiffness of the Jelly Sprite reference points on the side that you want to drag, perhaps relaxing the stiffness more as the velocity increases and smoothing the change rate (so as you come to a halt, it gradually tightens up again). The alternative would be to add a force to some of the reference points in the opposite direction to movement, so you're effectively pushing some of the bodies away from the centre and therefore stretching the Jelly Sprite out.

    For both approaches, you can access the Jelly Sprite reference points (from which you can get the Unity rigid bodies) using code like this:

    Code (csharp):
    1.  
    2. JellySprite jellySprite = gameObject.GetComponent<JellySprite>();
    3.  
    4. foreach(JellySprite.ReferencePoint referencePoint in jellySprite.ReferencePoints)
    5. {
    6.     // Do stuff, eg. apply a force
    7.     referencePoint.Body2D.AddForce(new Vector2(-1, 0));
    8. }
    so it should be easy to add a force/mess with the spring joints of individual bodies and not others. You'd need to look at the position of each reference point relative to the central point in order to work out where it was in relation to the direction of movement, and therefore whether it needs to be affected or not.

    Good luck! Hope that helps!
     
    Last edited: Oct 6, 2015
  43. Kinkku2

    Kinkku2

    Joined:
    Sep 29, 2014
    Posts:
    106
    Thanks a bunch for the answer! I'll try your tips out.
     
  44. Nitin_CMLABS

    Nitin_CMLABS

    Joined:
    Jul 10, 2015
    Posts:
    13
    I am using jelly sprites in my project.
    I am trying to change the sprite of Unity Jelly Sprite at runtime but it's causing error.

    It is not showing any command to change the order in layer, sorting order and sprite.

    Please let me know what do i need to do for this.
     
  45. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey,

    To change a sprite at runtime, you need to grab the UnityJellySprite component, assign your new sprite to the m_Sprite variable, and then call RefreshMesh to update the rendered mesh:

    Code (csharp):
    1. UnityJellySprite unityJellySprite = gameObject.GetComponent<UnityJellySprite>();
    2. unityJellySprite.m_Sprite = xxx;
    3. unityJellySprite.RefreshMesh();
    To change the sorting order/layer, you can simply access the renderer on any gameobject:

    Code (csharp):
    1. GetComponent<Renderer>().sortingOrder = 2;
    2. GetComponent<Renderer>().sortingLayerName = "Default";
    Hope that helps! :)
     
  46. Upside-Down-Bird

    Upside-Down-Bird

    Joined:
    Jun 11, 2014
    Posts:
    3
    I am thinking about getting this plugin for a future game. However I have noticed that when a jelly object has an outline the outline gets hidden by the ground. I understand why this is, however is there a way to conserve the width of the outline and squish the jelly more on the inside? Also it looks like the collisions aren't perfect as the mesh overlaps other sprites past the collision. Can this be fixed as well?
     
  47. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Hey,

    The Jelly Sprite rendering is always going to be slightly 'lossy' (for want of a better description), purely because its trying to warp a single mesh to represent the layout of multiple rigid bodies. Something like Jello Physics (unsupported, but free) might be a better approach if you want more accuracy, as that has a 'proper' jelly physics implementation whereby each vertex on the body is a physical object and therefore can't clip through other objects. It is much more computationally expensive however.
     
    theANMATOR2b likes this.
  48. Upside-Down-Bird

    Upside-Down-Bird

    Joined:
    Jun 11, 2014
    Posts:
    3
    Thanks for the reply. I have looked at Jello Physics and can not get it to do what I want. It does do better for collision detection, however it still does not look very good. I am creating a mobile game and I think your plugin would be a better fit because of performance. I am also having a lot of trouble moving Jello Physics objects without them being effected by the physics system (like for resetting a character to the starting position). If the only downside to your plugin is that it is lossy then I might still be able to use it. I am thinking if I make the character one color without an outline and make him always be drawn behind my colliders it might will look like it is perfectly colliding. Could you maybe send me a demo of something like this?

    Anyways I am trying to make a LocoRoco style game. Is this the plugin I am looking for?
     
  49. mrsquare

    mrsquare

    Joined:
    Oct 25, 2013
    Posts:
    239
    Yeah, that could work - it might be possible to use some sort of edge detection shader to add an outline around the visible pixels of each Jelly Sprite - sort of like a cell shading effect but limited to just the Jelly Sprite characters rather than being a full screen effect. I'm not really a shader expert, I'm afraid, but there seem to be a bunch of free tutorials and assets that might be of use (eg Toon Shader)
     
  50. waseem2bata

    waseem2bata

    Joined:
    Apr 17, 2014
    Posts:
    8
    any one knows how to make the attached eyes look where i touched ?