Download

Tiled map generation unable to work. HELP!

I’m somewhat new to blueprints and C++ but I’m trying my hardest to make strides, but I’ve hit what I think is a math roadblock. C++ was giving me headaches while trying to learn it so I thought I’d build up some knowledge in Blueprint first.

This is what I have so far in blueprint. This is in the ThirdPersonCharacter in the starter content pack.
This code is meant to generate a single hexagonal pillar mesh below the player (eventually it will be the origin point of the map), which it does. The next thing I’m trying to do is use a forloop to generate 6 more pillars around the origin pillar in such a way that they tesselate almost perfectly - just a slight gap between them. From then on, I would use more forloops to generate tiles out to the edge of the map until the specified map radius is reached. I would not need to worry about invisible barriers or any such nonsense, as the outermost pillars would grow in height to form an impenetrable wall.

Is there perhaps an easier way to do this? Am I doing something wrong with my math? I’m finding that degtorad turns whatever angle I specify as the offset for the secondary pillars into 0, thereby stopping the rest of the math from functioning correctly. Even doing my own manual degtorad calculation failed in this. Please explain in depth, not just how to do something but why as well, since knowing why UE4 does something a certain way is just as helpful as knowing how to do it.

I think you may have a problem at the bottom of your graph; you’re using ASIN, but I think you should be using SIN…

I’ve just noticed, you’re also using “%” for your deg-to-rad conversion, where I think you should be using “/”. The operation you’re using is the modulus operator, which divides by 180 and returns the remainder; you just want a plain divide operation here, which is “/”.

I’m not sure as I’m not at my home computer to try it out, but I’d also make sure whether the deg-to-rad is necessary; it could well be that the SIN and COS nodes expect the input values to be in degrees rather than radians.

Actually there’s two separate sin nodes. One is labelled ‘SINd’ and this is the one which uses degrees. The degrees one is probably more suited for what the OP wants to do anyways as it reduces unnecessary conversions :slight_smile:

I’m so sorry for not being back in so long. Life happened.
And then I sort of moved into streaming and didn’t have as much time for GameDev (focusing on gaming in the streams).
And 4.15 broke my project and I couldn’t even get it to go back.

But I’m back, and I have tried all the solutions listed by you guys. None of them worked. At worst, the surrounding pillars do not spawn at all. At best, they all spawn but in the same spot. I can tell that the loop is getting them to spawn, but they’re all using the same spawn location. Does anyone have any others ideas, perhaps simpler blueprints, in order to get a central pillar to spawn (I have this working fine), then using the location of this original pillar to spawn 6 others around it using a simple loop?

EDIT: I just started messing around again with a few new blueprint nodes and I managed to get some progress. It’s not what I expected or wanted, but it’s better than nothing. Instead of all spawning in the same location, they’re now spawning stacked up over a huge distance, so it seems I was affecting irrelevant numbers and in the wrong area of my blueprints. I’ll post again if I get what I’m looking for.