How to improve performance?

Hello All…

I have performance related problem in unity gaming… i am making a game like Kitty cannon http://www.addictinggames.com/funny-games/kittencannon.jsp

i want to make scrolling background like in this game … i made it… but having a problem of rendering

the steps followed to make scrolling background is…

  1. Take three plane a placed one after another where on plane ends.
  2. take a cube at a certain distance in front of first plane and it cast a ray in z direction and it moves when like kiteen move
  3. and after attach a script to object in casting ray

is there any other way to make a scrolling background, please let me know ASAP.

Thanks.

I don’t understand how you’re creating a scrolling background with this, but just as a note, comparing strings will be slower than comparing the transforms ( it will also cause garbage collection to fire frequently in your example )

function Update ()
{
this_ref_transform.position.x = camera1.position.x;

if(Physics.Raycast(this_ref_transform.position,Vec tor3(0,0,100),hit))
{
var hitTransform = hit.transform;

if(hitTransform == newref1 )
{
newref2.position.x = newref1.position.x + 14;
}
else if(hitTransform == newref2)
{
newref3.position.x = newref2.position.x + 14;
}
else if(hitTransform == newref3)
{
newref1.position.x = newref3.position.x + 14;
}
}
}

Sorry I haven’t helped directly with your question. Some more information would be good.

look up TextureOffset in the documents , it works great. It will help to clean up that excessive code as well.

Material.SetTextureOffset

Hi…

In this very case i have three planes used as background which are placed on after another in positive x-axis and my character is also move in positive x-axis … when my character reach at third plane starting which is “Middle_Cube3” then i change the position of first plane which is “Middle_Cube1” in this way it appear as background is scrolling/moving

I don’t understand why you’re raycasting and comparing string.
You know the positions of the planes and of the player, just move the transform of the various planes when the player reach a certain position, then rinse and repeat. :slight_smile:

Watch out for the overdraw, if you have three transparent plane covering the entire screen, you’re really pushing it on iPhone 4 and iPad 1.