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"

Hello all, How to create a cube in scene with Blueprint or C++ ?

Hello all, How to create a cube in scene with Blueprint or C++ ?

Product Version: Not Selected
Tags:
more ▼

asked Apr 24 '15 at 06:46 AM in Using UE4

avatar image

袁涛
6 1 2 6

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

2 answers: sort voted first

Hello, 袁涛

First thing you need to implement this in C++ is to declare an appropriate field in your class, which will look something like this:

 UPROPERTY()
 TSubobjectPtr<UBoxComponent> Cube;

After this, please don’t forget to initialize your cube in constructor of the class and configure in needed way:

 Cube = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("Cube"));
 Cube->bHiddenInGame = false;
 RootComponent = Cube;

Finally, you spawn the cube:

 GetWorld()->SpawnActor(ACube::StaticClass());

Please note, that ACube should be replaced with the name of your Cube class. If you like to learn how to do this using Blueprints, this tutorial should help you: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/SpawnAndDestroyActors/Blueprints/index.html

Hope this helped!

more ▼

answered Apr 24 '15 at 02:00 PM

avatar image

Gleb.Bulgakov
1.8k 76 19 143

avatar image 袁涛 Apr 25 '15 at 12:16 AM

Thank you, it really helped.

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

If you just want to spawn a Cube mesh in a level then in blueprint you can do:

  1. "SpawnActorFromClass" node

  2. Assign it the Class "StaticMeshActor"

  3. Plug a make transform node into the SpawnTransform property

  4. Plug the return value into a SetMesh function of its StaticMeshComponent

  5. Set the NewMesh property to a cube mesh. Several come with the Engine content

alt text

capture.jpg (58.0 kB)
more ▼

answered Apr 24 '15 at 10:33 PM

avatar image

RimmyD
2.6k 98 15 96

avatar image Bill熊 Jan 08 '16 at 03:53 PM

I tried this as this seems to be the easiest to test. I added a key event as a trigger to the Spawn Actor. However, I keep getting "Warning Mobility of StaticMeshActor_24 : StaticMeshComponent0 has to be 'Movable' if you'd like to move.", and no cube was spawned

(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