Hello Guys,
Project:
- Procedurally-generated block-based game (yeah, like Minecraft)
- Open Source
Experience:
- 4 years C#/Java
- 5 Months of C++
- Only a few days of Unreal Engine
- No Gaming Development
After quite a lot of googling and watching videos I didn’t find a lot of comprehensive C++ code regarding this topic. The HierarchicalInstancedStaticMesh(HISM) seems to be quite new and the Unreal Syntax looks a bit strange to me.
The code I have so far:
AChunk.h
UHierarchicalInstancedStaticMeshComponent* hismc;
AChunk.cpp
AChunk::AChunk()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
this->hismc = NewObject<UHierarchicalInstancedStaticMeshComponent>(this);
this->hismc->RegisterComponent();
this->hismc->SetStaticMesh(SM_Cube???);
this->hismc->SetFlags(RF_Transactional);
this->AddInstanceComponent(this->hismc);
}
This isn’t running code, only copied from other questions. I know so far, that there’s only one HISM per block-type needed and if I want to show more blocks I just call hismc->AddInstance(Vector). What I don’t know is, how to properly create an instance.
- Is the shown code correct?
- How do I get/instantiate a StaticMesh of a green(grass) block for the HISM?
- Do HISM child instances have colliding meshes to walk on them?
- What’s the relation between meshes and meshcomponents?
- Do the HISM children need to be recreated each tick or only when the blocks change?
- How do I find the block in my array, when my character looks and clicks on it?
A few sidenotes:
- No blueprints, pure C++
- A link to a tutorial on block and chunk generation. link:Here
I know this is a long question, but if you could answer only a few or point me in the right direction I would much appreciate it.