Portponky / better-terrain

Terrain plugin for Godot 4
The Unlicense
433 stars 21 forks source link

Changing terrain by code #82

Closed neepsnikeep closed 8 hours ago

neepsnikeep commented 2 months ago

Thanks for the great plugin! I want the player to change terrain, and the TileData.Terrain does not seem to be used by this plugin. I struggle to use the Terrains I set up in the editor.

I tried this:

    BetterTerrain test = new BetterTerrain(Map);
    test.SetCell(layer, facingTilePosition, (int)newTerrain);
    test.UpdateTerrainCell(layer, facingTilePosition, true);

What am I doing wrong?

Portponky commented 2 months ago

Hi, sorry for taking a while to get back to you. It is not clear what the problem is from this code, as it looks correct. Can you provide a more detailed example?

neepsnikeep commented 2 months ago

Oooh got it, sorry, the calculation for the newTerrain used the previous terrain and I forgot to use GetCell there instead of tileData.Terrain. Time to refactor! Thanks for confirming it's not this part of the code.