I need to create a particle system and retain the created particles. I need to shake / move the created particles with the iphone accelerometer. Also, the number of particles needs to be very high (I need to show sand!).
I have just started using unity.
Please suggest how this can be achieved and whether or if some kind of similar demo is available.
Unfortunately, it sounds like you might be being a little unrealistic with what you’re trying to achieve. Trying to model the realistic motion of sand is something that high end physics modellers do in labs, not soemthing you can do in a game engine on a mobile phone.
Do you want to make one of those games where the player draws in the sand with a finger? If so, do you need the sand to move when you shake the device or is that just a reset gesture?
Thanks for youe reply.
Ours is not a sand drawing game. We are actually trying to show an object covered in sand. The user shakes the iphone to move the sand and reveal the object.
Any suggestions??
Particles are probably the best way to do this. The particle emitter has a particles array that holds references to all the currently active particles, as you might expect. Each particle object in the array has a number of fields, including one for position, that you can set from a script. When you use particles like this, you need to set their movement to nothing and give them a very high energy to stop them disappearing during the game. You should also turn off emission and use the Emit function directly to release the particles.
There is actually only one way to realistically handle a situation like fullscreen sand (out of my view) and thats the way that has been used by Clonk and Worms since they use 3D acceleration as well:
Tiled images!
Dissect the screen into areas of 32x32 and modify them to handle the sand behavior there.
Due to the locality of changes in that sand, you will at max have 4 such areas affected by a single operation normally (as long as you don’t turn do large scale stuff but even then its not that many areas normally as you always only update the border that changes, not the area in thats static) you will have very low amounts of texture reuploads.
working with the textures (or alternative bool[,] arrays) is very fast and due to the pixel precision you also don’t have problems with rotating blocks or alike as you always operate on the distinct pixels.
I don’t see any realistic chance for sprites, particle systems or anything alike to even remotely compete with that as the overhead is massive and in addition you can’t do 480x320 pixels with distinct particles anyway, thats worlds beyond the amount of geometry you can have, aside of the fact that the update of the unified emitter mesh will be breaking your neck performance wise.
I might be wrong on what your actual intend is but if your “very high” is higher than a few hundred (without any overdraw), this is the way to go