Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mrsquare

Pages: [1]
1
Add-ons and Extensions / Jelly Sprites - Soft body sprite physics system
« on: December 05, 2013, 02:04:28 pm »
Hi folks,

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

Web Player

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 :)

2
Have added a little tutorial video to the first post :)

3
Support / Re: Physics 2D problem
« on: November 21, 2013, 05:19:44 pm »
Hey - yep, you want to use Physics2D.Raycast, not Physics.Raycast. As of 4.3, there are different raycasting systems for the two types of physics engines. To detect clicking on something, I use this:

Code: [Select]
Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

RaycastHit2D rayCastResult = Physics2D.Raycast(mouseWorldPosition, new Vector3(0, 0, 0), 0.0f);

if(rayCastResult.rigidbody)
{
    // Do Stuff
}

4
Some guys over on Reddit were asking for some example of the interface, so this might be of interest to some folk here too:

Code: [Select]
static void SliceAllSprites(Vector3 worldStartPoint, Vector3 worldEndPoint);
static void SliceAllSprites(Vector3 worldStartPoint, Vector3 worldEndPoint, bool destroySlicedObjects, ref List<SpriteSlicer2DSliceInfo> slicedObjectInfo);
static void SliceSprite(Vector3 worldStartPoint, Vector3 worldEndPoint, GameObject sprite);
static void SliceSprite(Vector3 worldStartPoint, Vector3 worldEndPoint, GameObject sprite, bool destroySlicedObjects, ref List<SpriteSlicer2DSliceInfo> slicedObjectInfo);

So you have the option of slicing any sprite that intersects the vector or you can pass through a specific gameobject if you know exactly what it is that you want to cut. The demo is using the first option, which is why you can get multiple things getting cut if you move the mouse fast enough.

SpriteSlicer2DSliceInfo is an optional parameter, which will get filled out with information on which slice generated which child objects from which parent object, so you can do any extra processing as required (eg. add particle effects at the cut positions, increment a score depending on what type of object the parent was)

The explosion code is as follows:

Code: [Select]
static void ExplodeSprite(GameObject sprite, int numCuts, float explosionForce);
static void ExplodeSprite(GameObject sprite, int numCuts, float explosionForce, bool destroySlicedObjects, ref List<SpriteSlicer2DSliceInfo> slicedObjectInfo);

It basically slices the object multiple times at random angles through the centre, and then applies an outward force to each child object away from the centre. I've got some ideas for improving this - specifically running a triangulation algorithm over the mesh and then creating the child objects from that. Should make a more pleasing shattering type effect with more evenly distributed polys (its a bit 'chunky' at the moment).

5
Hi folks,

I'm pleased to announce the release of Sprite Slicer 2D on the Unity Asset Store :)

Web Player

Tutorial Video

Sprite Slicer 2D allows you to cut any physics enabled sprite into little pieces, each of which then behaves as its own independent physics object. Its perfect for bringing your 2D game to life with destructible objects and environments, or for creating a Fruit-Ninja style cutting game.

* Works on both Unity and 2D Toolkit sprites.
* Simple static script functions allow you to slice sprites along a given line, or explode them into multiple parts.
* Optimised to preserve dynamic batching and reduce draw calls.
* Slices any sprite with a 2D box, circle or convex polygon collider
* Full C# source code and example scene included


The code has been designed to be as transparent as possible - there are no new gameobjects to create; you simply pass a cut start and cut end point to one of the static Sprite Slicer 2D functions, and the code will handle the rest. Once cut, each child sprite behaves as its own separate physics body, retaining all the physics and rendering properties of the parent object, and can itself be cut into further child objects. If required, the slicing functions can return a list of all the cut objects along with their child objects and cut positions, so that the user's code can perform additional processing once the cut has taken place. Equally, you can delay destruction of the parent object in the event that you need to access variables from it before it is destroyed.




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 :)

Pages: [1]