Fruit Ninja - Cut fruit effect

Hi fellas!

I want to make a game similar to Fruit Ninja and I don’t really have an idea on how to create the effect of the fruit cut in half. I thought about removing the fruit object and instantiate 2 separate objects with texture of fruit cut in half on them but I’m not sure if it’s a good way because I’m creating for iPhone. I’m afraid in the end, there will be too much objects on the screen (let’s say if the player cut 5 fruits, there will be 10 objects on the screen) and it will cause the game to lag. I appreciate any tips and advice about this. Thank you in advance =)

There is only one optimization in my mind at the moment. instantiate other objects with the main one and just set their property to false or just disable their rendering by setting renderer.enabled to false. You can even do this for the main fruites themselves. let's say this:

  1. Instantiate 5 Orange objects and 10 Orange parts if you at most show 10 of them at the same time.
  2. Then make all of them inactive by setting their active to false.
  3. when you want to instantiate a new orange just set active to true
  4. and when you want to destroy, just set it to false.

the technique is called polling and is very useful because you'll remove much of the overhead of instantiation. Also you can use Graphics.Drawmesh to draw meshes without having gameObjects but then you should calculate movements yourself and without using rigidbodies.

About alverndbl's answer i should say that it seems that he is talking about a solution that could cut meshes at runtime. it's really great for it's usage but doing it on the phone would kill your performance.

Well anyway you cut it (no pun intended) you’re going to have to be able to display MaximumFruits*2 objects on your screen minimum. You can curb the load a little bit by making the halves static geometry and batching them since at least 2 will be the same (if the fruit is perfectly bisected) and they aren’t animating. I honestly don’t think the rendering is that big of an issue performance wise, I wouldn’t instantiate them on the go as you suggest though. A better strategy would probably just be to define the maximum number of any given fruit that can be on the screen at once and then instantiate all the fruit halves for them when you load your scene and just don’t render or use them until a player cuts a fruit.

I think I saw something like this in the asset store. Had a webplayer demo too, can’t remember the name sorry.