Terrain map rotation?

I’m currently developing a shooter game and we want to have a map rotation. The maps are made with Roblox terrain tools and I have no idea how to store both maps in one game and show one at a time.

5 Likes

This is very much possible. Terrain can be stored using Terrain:CopyRegion() and loaded in again using :PasteRegion(). Keep in mind that the data stored by copying and pasting cannot be sent across the server-client boundary. You can learn more in this DevHub article.

This, below, is a simple example. It basically copies, destroys and pastes in terrain. The same code is found in the link I provided.

local terrainRegion = workspace.Terrain:CopyRegion(workspace.Terrain.MaxExtents)
workspace.Terrain:Clear()
wait(5)
local corner = Vector3int16.new(-32000, -32000, -32000)
local pasteEmptyRegion = false
workspace.Terrain:PasteRegion(terrainRegion, corner, pasteEmptyRegion)

Similarly, you can rotate maps by copying map1, then destroying it and loading map2 (which is to be copied when map2 is being rotated out) and vise versa.

I hope that helps!

4 Likes

Thank you. I’ll try it out and mark your answer if it works!

Worth the warning that pasting regions is extremely hard on performance, especially if you have a lot of terrain. A pure terrain map would be absolutely battering on performance.

When you paste a terrain region, you’re giving the engine a huge chunk of terrain to render within a small time period. There have been a few complaints about terrain pasting causing crashes or large latency.

If you ever get the opportunity to learn how (I haven’t), it’s worth learning how to copy the terrain in quadrants and then pasting those in.

6 Likes

It’s actually faster if you do paste empty regions. An engineer explained this to be a few years ago, & I’ll try to find that in a minute

1 Like

well 9 hours later it seems that no good solution has been found. I’m going to talk to my friend at darpa.

Can this be used to rotate a HUGE terrain map by 90 degrees?

1 Like

Different kinds of rotation. I meant for storing and loading different maps like in CoD or CS. You mean physical angle rotation, of which I think you can use region tools in the terrain editor to accomplish.

Yeah, my problem is I have an enormous map that’s like literally thousands of studs wide, and i decided I want east and west to be differnet, but there’s no way to change the direction of the suns movement, just where it is in the sky, so… i figured if i could find a loophole to rotate the WHOLE map including the terrain, then that would be best.

1 Like