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"

Cannot spawn blueprint cubes from c++

Hi, I'm pretty new to UE4 but I have been having an issue where I cannot spawn mesh cubes into the game. What I've done is create a blueprint based off of a c++ class and in the blueprint editor I gave it a cube mesh. The code I use to spawn the blocks is the following, In my constructor:

     static ConstructorHelpers::FObjectFinder<UBlueprint> ItemBlueprint(TEXT("Blueprint'/Game/TopDownCPP/Blueprints/TerrainBlock.TerrainBlock'"));
     if (ItemBlueprint.Object)
     {
         TerrainBlockBlueprint = (UClass*)ItemBlueprint.Object->GeneratedClass;
     }

and then in my actual method:

 void Main::Generate()
 {
     UWorld* World = GetWorld();
     FVector fVector;
     FRotator fRotator = FRotator(0, 0, 0);
     if (World)
     {
         fVector = FVector(20, 100, 0);
 
         World->SpawnActor<AATerrainBlock>(TerrainBlockBlueprint, fVector, fRotator);
     }
 } 

Just to test this out I called the Generate method from the GameMode constructor and I set a keybind to it and called the Generate method from the PlayerController. Neither worked unfortunately.

Product Version: UE 4.11
Tags:
more ▼

asked Jun 30 '16 at 05:54 PM in C++ Programming

avatar image

shardstealth
1

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

1 answer: sort voted first

I actually figured it out, the issued was in the fact that the classes I made were into the project and not created via the unreal editor. When I made a new project and did it properly the placing worked.

more ▼

answered Jul 11 '16 at 11:51 PM

avatar image

shardstealth
1

(comments are locked)
10|2000 characters needed characters left
Your answer
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