x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Procedural generation of tilemaps.

I'm currently working on a simple tool that allows me to pull out a spline whatever distance and generate tilemaps a certain height and width to match that spline. At the moment you can pull out the spline and then I generate the tilemaps as objects at runtime.

alt text

When I click on each individual component in this blueprint after they're generated I'm allowed to edit said tilemap which is ideal as I'd like to edit individual tilemaps by hand for certain things. The problem is when I click on a tilemap to edit, it only ever lets me the first generated tilemap component that was created, nothing else.

alt text

As you can see, if I try to edit the tilemap to the left, it won't let me, says I'm outside of the map of the first tilemap which is to the right. I dunno if this is a paper2d bug or I'm missing something in my implementation.

Any help is appreciated, Thank you.

Edit: The main implementation of this little thing is done in c++:

 void AProceduralTileMapGen::GenerateMap(FVector Relative_Location, int MapNum, FRotator SplineDirection)
 {
     
     FString Name = (TEXT("GeneratedMap_" + FString::FromInt(MapNum)));
     FName MapName = *Name;
 
     
     //Create a map component, provide it a generated name.
     UPaperTileMapComponent* MapComp = NewObject<UPaperTileMapComponent>(this, TileMapSpawnClass, MapName);
     if (!MapComp)
     {
         UE_LOG(LogTemp, Error, TEXT("Couldn't Create Map"));
         return;
     }
 
 
     //Register the component and adjust it's width/height
     MapComp->CreateNewTileMap(MapWidth, MapHeight, TileSizeSquare, TileSizeSquare);
     MapComp->SetWorldLocation(Relative_Location);
     MapComp->SetWorldRotation(SplineDirection);
     MapComp->RegisterComponent();
     FName InSocketName = NAME_None;
     MapComp->AttachTo(MapLayoutSpline, InSocketName , EAttachLocation::KeepWorldPosition);
     MapComp->bSelectable = true;
     MapComp->bEditableWhenInherited = true;
     MapComp->MakeTileMapEditable();
     MapComp->RebuildCollision();
     this->AddInstanceComponent(MapComp);
     StoredTileMap.Add(MapComp);
 
     FillTileMap(MapComp);
 }

This is the code that the generator calls to create the tilemap component and then add it to the instance.

Product Version: UE 4.20
Tags:
generation.jpg (405.7 kB)
tilemapselected.gif (313.6 kB)
more ▼

asked Oct 30 '18 at 07:22 PM in C++ Programming

avatar image

Demoneyejin
95 10 15 26

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question