Reading the documentation that Digger Pro provides it looks like it does support procedurally generated terrain at runtime but what happens when trying to use it together with Map Magic 2 is that the only terrain in which I am able to dig is the one in the pre-generated chunk, if I move to another chunk that is generated during play mode the digging will not work there. I’ve tried their runtime script but without success. In their documentation they mention that a specific method (“SetupRuntimeTerrain method of DiggerMasterRuntime”) has to be called but they do not mention where or when to call this method (is a new script file necessary or should the method be called in one of the scripts already provided, etc).
If anyone has managed to have these two plug-ins work with each other let me know what is it that I need to do (mind you I have little to no programming knowledge so if you do know how to make it work I’d appreciate a lot if you could detail your answer at least a bit if possible).
Thank you very much.
I’ve managed to have them work with the help of the developer, no further assistance is required here.
OP Didnt leave an answer here, but since this is the thread that is given by google when you search for the issue of making other tiles in mapmagic diggable. I will answer it here.
The secret lies in ensuring that whenever a new tile is created, it should be given the ability to dig. the documentation states:
“If you use MapMagic 2 and want to setup Digger on terrains generated at runtime, you’ll need to call diggerMasterRuntime.SetupRuntimeTerrain(terrain);method every time after a new terrain is ready.
Fortunately, MapMagic provides a way to subscribe to events that will let you know when a new terrain has been generated.
Here is a script example showing how to react to such event. Just add this script to an object in your scene and it should work.”
using System;
using System.Collections;
using System.Collections.Generic;
using Digger.Modules.Runtime.Sources;
using MapMagic.Products;
using MapMagic.Terrains;
using UnityEngine;
public class MapMagicDiggerIntegration : MonoBehaviour
{
private DiggerMasterRuntime digger;
private void OnEnable()
{
digger = FindObjectOfType<DiggerMasterRuntime>();
if (digger) {
MapMagic.Terrains.TerrainTile.OnTileApplied += onTileCompleted;
} else {
Debug.LogError("Could not find DiggerMasterRuntime object. MapMagic Digger integration will be disabled.");
}
}
private void onTileCompleted(TerrainTile tile, TileData tileData, StopToken stopToken)
{
if (tileData.isDraft)
{
// We do not want to setup Digger on draft tiles
return;
}
Terrain? terrain = tile.GetTerrain(false);
if (terrain == null)
{
terrain = tile.GetTerrain(true);
}
if (terrain == null)
{
Debug.LogError($"Could not find tile's terrain. Unable to setup Digger for tile {tile}");
return;
}
digger.SetupRuntimeTerrain(terrain);
}
}
3 Likes
can you please help me fix the issue that i am using digger pro runtime , i am trying to save the modifications made on terrain , the holes i dug are persisted but the textures on the terrain over the holes are not updated when i run the game next time, they only update as soon as i dig somewhere near them