Is the performance worse in the build or editor only? Do you mean for MM2 or unity in general?
Infinite tile generation and draft tile to main tile conversion takes a significantly longer time when compiling using IL2CPP. Everything else works as expected. This doesn’t occur in the editor, only in builds.
Any idea how to sample in which biome the player currently is?
I’m currently sampling the terrain and checking the ground texture on players position, but I reuse some of the textures, which then cause problems.
Yes, there are special nodes to output maps information like biome masks:
If you want to know if player is in some biome you can assign this biome’s map to DirectMatrix in parent graph (where BiomeSet node is located) and get this biome’s value with FindHolder.GetValueAtPosition.
Very nice, exactly what I needed. Thank you.
Hi @Wright, great tool!
I have some questions regarding the scriptability:
- How can i set the physics material of each tile?
- I have a usecase where i want to exchange the Graph of a terrain at runtime, how would something like that be possible? Do you have any idea how something like that could be made possible without lagging?
- EDIT: i only want to run decide between 2 different terrains. Does that change it a bit? I tried setting the terrains active/inactive but that produced alot of lag
- I would also like to change some constants of my graph at runtime (for textures), how would you do it?
Once new tile is generated it will fire OnTileApplied event (Events). Here you can get terrain with terrainTile.main.terrain or terrainTile.draft.terrain (for draft), get collider component and modify settings here.
Changing graph in runtime won’t work. Obviously, if MM has already generated anything it won’t weld with new data. If you do it on scene start - it’s better to you two scenes and define with script which one should be loaded beforehand.
Yes, if change is not complete graph replacement, but just value modification - NP: modify exposed value or modify node value from script. Don’t forget to re-generate all after. Here.
Thanks for your answer, i tried out the multiple scene approach and it works fine What i noticed is that it still takes a while to generate all the tiles after switching to the other graph, so iam thinking about a different solution.
I was thinking about solving the issue like this:
- Run both graphs at the same time
- Use an event to subscribe to whenever a tile is applied
- disable the tile if its the wrong graph
- store all tile game objects in a list and disable/enable the specific list if the game switches to the new graph
This allows me to use the normal calculation logic of MM2 without any issues.
private void OnEnable()
{
TerrainTile.OnTileApplied += DisableTileIfOtherGraph;
}
private void DisableTileIfOtherGraph(TerrainTile tile, TileData data, StopToken stop)
{
var isWorld1 = tile.mapMagic.Graph.IdsVersions() == w1GraphId;
if (isWorld1)
{
W1Objects.Add(tile.gameObject);
}
else
{
W2Objects.Add(tile.gameObject);
}
tile.gameObject.SetActive(_activeWorld1 && isWorld1);
}
The code works fine for the initial first tileset of world1, but the moment i switch over the whole graph is broken.
- Could it be that running two MM2 instances at the same time is problematic?
- Could it be that disabling tiles is problematic?
I guess this one is the issue. MapMagic tends to enable/disable tiles on it’s own depending on how far camera is.
Hello, could MM2 with all modules be used for a low poly terrain? I need a way to do procedurally-generated terrain with biomes, roads, etc but want to keep the poly count low so it fits into a low poly/3d pixel art game.
MM is terrain generator, it doesn’t change the look or shader of the terrain. It can generate terrains of low resolution, but they will just look like… low-resolution terrain. Not triangles with sharp edges.
That’s what I mean - I want low resolution terrain but I want the “magic” of the terrain generation system, like biomes. I just don’t want high-definition mountains and such featured in the demo photos. What would I do to control the resolution/definition?
Thanks.
Also, what do you advise when using FishNet or another multiplayer tool? Ideally, the server would generate land and objects and communicate that that clients but since this is all seed-based and should be exactly the same gen each time, it’s probably safe to let each game client run normally as long as it’s getting the seed from the server?
I’ll also need to save objects as removed (chopped trees) etc so the server will need to tell clients about that as well.
Hi, its me again I have some questions
- Do you have any tips on using MM2 with large terrains + a fast moving player character?
- Is it possible to calculate the Height of a given point XY of the terrain (really far away)? Usecase is that i would like to place a gameobject far away via code, but i dont want that the object is under the terrain
- How would you manage to send a list of values to a graph? I would like to place biomes on exactly 100 spots, defined via code. Do i have to create 100 different expose values by hand or is there a different way? I havent found a way to send a texture (with 1x100 size) to mm2 yet
- I couldnt find a way to lerp between 2 values, except for creating the nodes by myself. Did i miss that somehow or is lerping not a node?
Yes, this should work. As long as you you don’t need authoritative server for cyber sport you can let clinets generate levels.
You can store <position,tree> dictionary of chopped (not all) trees on server, and apply it to clinets at slient’s OnTileApplied event (FAQ)
Well, other than reduce resolution try not using “heavy” nodes - like Erosion with high iteration count. You can find out how heavy node is in node’s Debug tab when you enable debug in Window - MapMagic - Settings.
The thing is that most of the nodes require information about neighbor pixel positions, and these pixels require info about their neighbors, and so on and so forth. It’s not a shader where you can calculate the value of each pixel independently. The only reliable way to get the height is to generate the tile.
If you want to send the list of 100 spots you can use a Position node that operates with the array of positions. You can assign this array with script - here’s how.
It’s Mask node.
If you want to send the list of 100 spots you can use a Position node that operates with the array of positions. You can assign this array with script - here’s how.
The position node is for objects right? What if i want to have 100 islands in specific spots using MM2?
If I wanted the server to generate the terrain objects, would I be able to tell mapmagic to call the ServerManager.Spawn
code that FishNet uses when spawning items?
I’m not sure that’s my issue but I’m sure it’s important. If I wanted the server to “drive” the terrain/spawned items instead of each client, how would I do that?
Using a basic scatter/object output for testing, I’m seeing that all of my objects are being generated in the scene but all but one are getting disabled when the fishnet server starts starts when I enter play mode. None of the objects are visible in the game.
You can use Stamp node to draw Simpleform cones at object’s positions, and then add some noise to convert them into islands.
I’m not familiar with FishNet and the way it works, but you can use OnTileApplied event on server side, and iterate in all objects on applied tile to call ServerManager.Spawn
So as the player moves around the map, are tiles just “moved” so they’re re-used? What happens to all of the objects inside of a moved tile?
I’ve gotten OnTileApplied
logic working so that I can call ServerManager.Spawn
but now I need to handle when a tile is “unloaded” and/or moved.
I see the OnTileMoved
event but it seems like OnTileApplied still fires. Is there an event that fires before a tile is “unloaded” so I can properly despawn all of the objects through the server?