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"

Spawning Actor within another Actor

This time i really need help. Documentation of this all is pretty poor and i came up asking here. Well to create continous level i need to implement custom terrain (and terrain is a just a bunch of merged procedural planes) tho i created an actor which creates a procedural mesh and registers it (let`s call it Tile) and when i place it into the world everything is fine but when i try to create another actor Terrain, for example, that creates a bunch of Tiles, they don`t apper in world. I know about UWorld::SpawnActor but it`s only spawns actors without any changes and it`s not working for me because i need to modify that tiles

 ATile *temp = NewObject<ATile>(this, ATile::StaticClass());
 temp->SetActorLocation(position);
 temp->AttachToActor(this, FAttachmentTransformRules::KeepRelativeTransform);

inside tile mesh = CreateDefaultSubobject(TEXT("GeneratedMesh")); RootComponent = mesh;

     TArray<FVector> aVertices;
     TArray<int32> aTriangles;
     TArray<FVector> aNormals;
     TArray<FVector2D> aUV0;
     TArray<FColor> aVertexColors;
     TArray<FProcMeshTangent> aTangents;
 
     for (int y = 0; y < 32; y++) {
         for (int x = 0; x < 32; x++) {
             aVertices.Add(
                 FVector(
                     x * 100,
                     y * 100,
                     0
                 )
             );
             if (x < (32 - 1) && y < (32 - 1)) {
                 aTriangles.Add((x * 32) + y);
                 aTriangles.Add(((x + 1) * 32) + y + 1);
                 aTriangles.Add((x * 32) + y + 1);
                 aTriangles.Add((x * 32) + y);
                 aTriangles.Add(((x + 1) * 32) + y);
                 aTriangles.Add(((x + 1) * 32) + y + 1);
                 aNormals.Add(FVector(x, y, 1));
                 aTangents.Add(FProcMeshTangent(x, y, 1));
             }
             aUV0.Add(FVector2D(x / 32, y / 32));
             aVertexColors.Add(FLinearColor(0.75, 0.75, 0.75, 1.0).ToFColor(true));
         }
     }
 
     mesh->CreateMeshSection(1, aVertices, aTriangles, aNormals, aUV0, aVertexColors, aTangents, true);
     mesh->RegisterComponent();
Product Version: UE 4.15
Tags:
more ▼

asked Aug 11 '17 at 10:01 AM in C++ Programming

avatar image

Gordy96
1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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