1
\$\begingroup\$

I am making an RTS game and want to add the ability to dig a trench without redrawing the whole terrain as that is causing lag. The solution would need to allow a user to build a trench on the map and have a unit able to stand in the trench. The game is using 3d models at the moment.

My first thought was to have the trench on a layer that is rendered on top of the layer with the terrain but that would give the problem that a trench would be seen even if it was behind a hill.

Is there an alternative or a solution?

\$\endgroup\$
4
  • \$\begingroup\$ Can you show us what your current (if laggy) method looks like, both in terms of implementation and visual result? This can help lead us toward solutions to achieve a similar visual result more efficiently. \$\endgroup\$
    – DMGregory
    Oct 6, 2018 at 14:28
  • \$\begingroup\$ Is this a 2D game using sprites or 3D with models? How are you drawing the trench now that is causing lag? \$\endgroup\$
    – Ed Marty
    Oct 6, 2018 at 14:29
  • \$\begingroup\$ @DMGregory I have not tried to implement drawing the map with the trench appearing, just redrawing the terrain exactly the same when a new building is made to check the speed. \$\endgroup\$
    – PStag
    Oct 6, 2018 at 20:12
  • \$\begingroup\$ Sounds like you should tell us how you do that, then. It might give us some hints where the slowness is coming from. \$\endgroup\$
    – DMGregory
    Oct 6, 2018 at 20:17

1 Answer 1

1
\$\begingroup\$

Divide the terrain into sections, then replace only the section where the trench is dug. This technique speeds up the game.

\$\endgroup\$

You must log in to answer this question.

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