Download

What to use for flat grid-like ground?

Hi, I am working on top-down perspective project where I would have flat 2D ground as the main part of the world and 3D objects (like trees or rocks) on it. Also I need the ground to be divided into grid-like “tiles”, each with their own sprite and potentionally functionality. They need to have texture and custom functionality (I need them to change texture based on what type of ground they are, keep track of time, spawn objects etc.).

What should I use, I am new at C++, switched from Unity and the only things I have come up with is using square actors as tiles or maybe 1 actor as multiple tiles at once?

Yeah I have no idea, really, please help me.

To render tiles use the Hierarchical Instanced Static Mesh and check coordinates of characters according to the corresponding tiles grid in the form (loc * grid size) / grid size. For grid data use the structures array.

Took a look at Instanced Static Mesh, looks promising, although I couldnt find much documentation on it, especially not in C++ so that might be a problem. Any links?

As for the grid data, should I use Data Tables?

The HISM is very simple:



// creating HISM once
hismc = NewObject<UInstancedStaticMeshComponent>(this);
hismc->RegisterComponent();
hismc->SetStaticMesh(YourMeshReference);
hismc->SetMaterial(0, YourMeshReference->GetMaterial(0));
AddInstanceComponent(hismc);

// and then instaniation
FTransform t = FTransform();
t.SetLocation(NewLoc);
hismc->AddInstance(t);


Also I recomend to use per instance custom data to modify tile material instead of material instances, it will reduce draw calls without serious restrictions. For this technique you need to setup your hism material data floats by hismc->NumCustomDataFloats = <num of needed floats>
https://www.ue4community.wiki/using-…-mesh-bpiygo0s

About grid data I dont know your game mechanics, it depends on what you want.