Ok, here’s what I have in mind. The mesh below represents my whole map. The grayscale image above it is invisble/internal, but every point on the map that an object can be or go corresponds to a point on the image and thus a value from 0 to 255.
Then I use the gray value to modify some variable in a script attached to the object. (The map doesn’t belong to that specific object, any object can access it.)
But I also want to be able to modify (generally, add or subtract a fuzzy-edged circular spot) this image in-game using scripting.
Is there a way to do this?
Easily?
Little help, please? (I can’t yet Javascript my way out of a wet paper bag.)
Or is this a stupid way to go about it anyway?
The alternative to accomplish the same thing is to create an invisible object in world space that has a falloff radius and a decay time and check for and average the influences of all such nearby objects. I’m worried that late in the game the map would be cluttered with these influence objects and slow things down too much. The image would be expensive to “write”, cheap to “read”, but “read” events will be far more frequent.
I think I also want to have non-editable maps corresponding to individual terrain tiles- for example- probability that a certain decorative plant or powerup will appear there.
I’m not using Unity Terrains for my “terrain.” The terrain engine is a cool feature but specialized in the wrong ways for what I want my game to look like.
I’m using ordinary mesh objects- lots of them, tiled together.
I’m afraid you’ll need to build something yourself for this. How will the terrain be textured? Are these simple tiles or will they have to be blended textures like the unity terrain? I’ve something simple made that I use for my own project (although possibly I’ll have to revamp that part in near future). It’s written in C# and basically it makes for every tile type a mesh using a height-map (currently a 2-dimensional array, but that isn’t that different from a grey-image). It also generates a separate mesh of all tiles for the collision mesh.
Furthermore for performance reasons, you can have the area split in several subarea’s (for example a field of 20x20), because modifying one point means to rebuild the meshes affected completely, so with a ‘huge’ (say 100x100 or bigger) terrain the modification would give an annoying delay.
If you’re interested I could give you the code (have to remove some dependencies to other code first) but it’s basically prototyping code so not that readable and I wouldn’t be able to give much support on it (hey I’ve got deadlines, you know ;-)).
To see the code working you can find a test build of my project so far (not far) at Ctrl-J - About Ctrl-J
To calculate where to focus I do simple cast some rays from a few points in the centre of the screen. If you like I can give you the code, although there are some dependencies to my other code, like the camera has ‘preference’ to focus on a bird and stuff like that. Just let me know.