Calling Terrain:PasteRegion() after Terrain:Clear() causes terrain to have no collision

Running this code in a script or localscript causes the pasted terrain to have no collision.

local TerrainCopy = workspace.Terrain:CopyRegion(workspace.Terrain.MaxExtents)
wait(5)
workspace.Terrain:Clear()
workspace.Terrain:PasteRegion(TerrainCopy, workspace.Terrain.MaxExtents.Min, true)

The terrain still renders normally but has no collision. This bug can be mitigated by putting a wait() between clearing the terrain and pasting the terrain.

Steps:

  • Run the code from client’s command bar on a terrain Baseplate.
  • You will fall through the terrain and this effect will persist after respawning.

  • Run the code from server’s command bar on a terrain Baseplate.
  • Any parts will fall through the terrain, but the player will stay on the terrain.
  • Newly added parts behave strangely and will collide with terrain normally if spawned on top of your character for example, but will fall through if moved with Studio tools. There appears to be some disagreement or desync between client and server about part positions (Network ownership?).

https://gyazo.com/02022228606ce2055f46f02071616a71

2 Likes

Confirmed. Working on Fix ASAP, will try to make sure it ships in next release!

Thank you for the report.

Got it in for the release next week. Will monitor!

4 Likes

By the way, I rolled this fix out yesterday. Can you confirm that this is resolved for you? (Provided you use latest version of Studio or are using our Servers).

May take some time for this to roll out on Xbox or mobile platforms.

1 Like

It looks like it’s fixed. Nice job!
I was guessing it was a race condition, was I right or wrong?

1 Like

No, it was the way I deferring some terrain work in the engine. I was dumping “deleted terrain” and “updated terrain” into separate containers that didn’t check each other.

What happened was that every frame, we would go through these containers and do work, and “deleted terrain” was always the last thing processed. So if you would delete and recreate terrain there would be an entry in the “updated” and “deleted” containers.

Rookie mistake.

Putting a “wait()” simply caused the two operations to be split and properly ordered.

I am still having problems with terrain collision, although a little different. Characters seem to “slide” across it, and are unable to jump while this is happening. This was just this morning:
https://i.gyazo.com/01cb715eb14010456e62f67eaea1af6a.mp4
This occurs pretty rarely, around once every 20 times I join the place. Unfortunately, I have no idea how to replicate it reliably, but I know that a plugin was used to move this terrain over a week ago, which makes me think it is related. There are no scripts modifying the character in any way.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.