Download

How to create localised 'temperature' zones like Divisions' Survival mode?

So I have posted this all over, got a bit of response from the subreddit, also posted on the answer hub, but then read somewhere that the forums where a better place for discussion and as I don’t know the specific answer I need I guess is the right place for this. If you have read this somewhere else, I apologise, but I am looking forward to a solution.

Essentially I want to have areas (every 50m or so) across my map with different temperatures like in Divisions Survival mode, so going up a mountain starts getting colder, down on the plains is warmer. The first thing I tried was a blueprint with a trigger volume, upon overlap cast to CharacterBP and set the ZoneTemp variable. This does work exactly how I want, but I want my map to be 50 square kilometres, so having to place every single one of these and set each temperature seems like a massive pain.

The idea that I came up with was to use a texture of the whole map with a gray scale image of where I wanted temperatures, the lighter it is the warmer it is, the darker it is the colder it is. Then just convert player location into UV coordinates and see what colour was at that pixel location. This would then update every 5 seconds or so. It made sense in my head, but upon giving it a go, I have no idea how to grab that pixel colour and convert it into a number to do something with.

On the subreddit someone gave me the idea of using something similar to lightprobes which would then be all across my level that could then get a value somehow, then the character could interpolate between these values to see what the average temp was in that location, but with no documentation on something like this I have absolutely now idea where to start.

If anyone can give me a steer in the right direction to use either of these 2 solutions (or has an idea of any other solutions) that would be great, just a little bit stuck at the moment!

You’d go through a lot of hoops trying to get the color information from a texture file or material. Though I’ve never actually dabbed in this area, I’m around 90% sure that it would require c++ to pull it off.

You could do something hacky like convert the bitmap into a spreadsheet(using some external converter) where each cell/column corresponds with the texture XY data. From there, you’d make a data table and from within the blueprints, you’d do some math to figure out what position to look up and then pull the row/column value to get your result. You’d take your landscape size and map it’s range to fit within your data table size. You’d need to get your character’s location relative to the landscape location because not all landscapes are centered at 0,0. You’d probably need to do some interpolation where it periodically blends your current cell with the previous cell. It might update the values every so often so that if you were within the same cell for a period of time, the “previous” and “current” would equal the same and it would be at it’s actual temperature value; for that cell. So let’s say you started off in a cell that was 30C and then walked into a cell that was 10C, you could take an average or geometric average or harmonic average, etc etc and get a value like 20C. So for that current update period, it would be at 20C. An update would come through again, but due to staying within the same cell, you’d get 10C and 10C and therefore it would just equal 10C now. You could also just use a finterpto node and control the blending speed there. Basically, something along those lines would help interpolate the data so that it wasn’t so rigid. I don’t know how efficient that would be for something like even a 1024 image(over a million entries) because I’m not 100% sure how UE handles data tables and memory storage, but it would probably work.

EDIT: For the above example, you’d want to make sure that the “origin point” on the terrain was the top left corner, which would be the first spreadsheet entry, and the bottom right corner would be the last entry of the spreadsheet. You’d just have to perform some offset math to derive it. You don’t actually have to move the pivot point.

Using probes would work fine but you’d be in the same boat as setting up trigger zones where you’d have to dial them in manually. You’d just make a blank actor and give it one exposed variable like “Temperature” and place them throughout the level; while setting their temperatures in the viewport(click on the actor and on the details panel, you can manually set their values). From within the character or BP, you’d have to do a “get all actors in radius” with a sphere overlap actors node and set it to filter for only the probes. From there, you’d do some distance checking and narrow it down to the nearest two or three. Finally, you’d cast to each of the actors left, get their temperature values and perform some math, like in the previous example, to blend the values.

Maybe a simpler idea but couldn’t you use the players position. Say if the player has gone up on the z axis by a certain amount above the ground level, the temperature value goes down by an amount? I don’t know if that would work?

Thanks both for replies!

Yeah I wanted a solution that didn’t take too much setting up but still was realistic (or at least seemed realistic in a game setting). I do like the idea of using the data table to give it information, I think using something like that eases up a lot on the manual clicking through items in the world.

Someone on the answer hub suggested a biome idea that I think I will go for. Essentially have large scale world modifies for time of day, weather etc, but then have localised large biomes (snow, desert, forest) with settings, then even smaller volumes in there where I need them to adjust it further. Then using some kind of fall off as to how far away you are from these volumes as to how much it affects your temp. I will report back when I have something further to show! Thanks for the help.

No problem! And I just thought up another idea that would be an extension of the probe based actor concept that I didn’t think of previously. From within it’s construction script BP page, you’d just set it to get Z-height, based on your “sea level” or whatever you deem to be you base altitude and set the value of the temperature variable from a formula that maps 0-1000 zunits to 0-30C or whatever numbers you want to use. That way, it would just put it in the level and it would automatically set the temperature for you. You could also put in an override boolean, that bypasses the construction script value, so that you could manually change the temperature to an area like being near a giant open freezer door, but down in a valley near the base of a mountain.

The biome style of handling could be done very similarly to the probe method. You would have it periodically scan for the player character and when the player comes within it’s desired radius, it can then cast to the player>send/receive information>change weather stuff>etc. You could use a sphere model, set to hidden within game, with a transparent material to help place them and give you a visualizer for things like their radius. Once you were done placing them all, you could just edit the BP and remove sphere model if you’re worried about it secretly making you lose 30fps lol…