I am making an RTS game which is having performance issues.

Is it possible to render the ground and units separately so I can only render the ground when the camera moves but keep the result displaying the units over the top?

I'm not sure what details to include but:

*The camera is fixed angle and orthographic

*The profiler says drawing takes up about 50% of CPU when units are moving.

*All the logic is done by a c# script outside of monoDevelopment but called through a gameobject each frame, (takes 2% of cpu in tests).

*Units are put in place using the "transform.position" command each frame.

*Units and tiles are instantiated and destroyed when the Camera passes them.

*The game is using rigged .3ds models for the units.

*The units have disabled rigidbodies.

*Each tile in the game is a separate sprite.

*The performance drops with ~100 low poly units without animation or ~20 higher poly units with animation.

Example screen

Profiler results

  • 1
    \$\begingroup\$ Yes indeed. Have you done any reading yet on RenderTextures? Note however that this solution won't help you when panning the camera, and might be trickier to get proper shadowcasting between the groups. There might be other ways to improve your performance without these complications— can you share an example screen, info on how you've set it up, and details of your profiling results? \$\endgroup\$
    – DMGregory
    Feb 10, 2018 at 13:17
  • \$\begingroup\$ @DMGregory Thanks for your reply, I am new to graphics so I am not sure what details would be helpful but I have included as much as I can think of. \$\endgroup\$
    – PStag
    Feb 10, 2018 at 14:30

1 Answer 1


Well, from your list, I can tell you somethings that may be the cause of lag:

  • Destroying and creating objects:

I think this is what is overkilling your performance. Creating and destroying them over and over, especially in large count, usually drops your performance (this is from experience). One fix would to be to simply place the objects in the scene and moving the camera via script.

  • Setting the position via transform.position.

This could be causing the lag also. As far as I can tell, it seems pretty pointless to do so every single frame (unless there is something I am missing). You should only change their position that way only when you need to.

Another thing that may help a little is instead of having all of those ground tiles, create a tiling material and apply it to a very large plane. This should create the same effect (unless you have other tile types that wouldn't fit with that).

  • \$\begingroup\$ The set position is how the units move, is there a faster way? I actually don't have a problem when the camera is moving even when it has to create +100 units plus tiles. \$\endgroup\$
    – PStag
    Feb 10, 2018 at 15:06
  • 1
    \$\begingroup\$ You could try using MoveTowards (read the docs for more details) \$\endgroup\$ Feb 10, 2018 at 16:17
  • \$\begingroup\$ I'd expect MoveTowards to include more overhead than transform.position setting directly, since both ultimately set world position, but MoveTowards also includes logic for partial moves and avoiding overshooting. Either way, I doubt moving positions is the major bottleneck here. I agree combining the tile sprites will likely give a substantial savings - have you tried using the new TileMap system? \$\endgroup\$
    – DMGregory
    Feb 10, 2018 at 18:14
  • \$\begingroup\$ I agree that each tile having a separate sprite renderer can be a bottleneck. If your terrain is flat and tile based you should use custom or asset store tile solution (that combines tiles or uses pools if not many tiles are active simultaneously). Or alternatively Unity's built in Tilemap can be an option. There is a very useful addition for the Tilemap on the Unity's Github, called 2d-extras (if I remember the name correctly). \$\endgroup\$
    – Nikaas
    Feb 12, 2018 at 7:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .