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"

static mesh rotation

I've created a new C++ class using Actor as the parent class and only added a StaticMeshComponent:

 UPROPERTY(EditDefaultsOnly, Category = Mesh)
 class UStaticMeshComponent* TestMesh;

The constructor looks like this:

  // 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;

 TestMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TestMesh"));
 TestMesh->bReceivesDecals = false;
 TestMesh->CastShadow = false;

 RootComponent = TestMesh;

I then create a blueprint class from this C++ class and am spawning the actor into the world. When it spawns into the world it's not facing in the right direction.

When editing the defaults (by double clicking the blueprint class) and looking at the static mesh in the viewport in the editor, I see that there is a Transform tab which has Relative Location and Relative Rotation but pressing the E key doesn't allow me to visually rotate the mesh in the viewport. It looks like all of the W-E-R tools are grayed out and you can't select them.

Could anyone explain why this is? Is there a way to visually rotate the mesh in the viewport or is my only option to specify values manually?

Product Version: UE 4.18
more ▼

asked Dec 10 '17 at 01:52 AM in C++ Programming

avatar image

48 10 14 21

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

1 answer: sort voted first

Try adding BlueprintReadWrite to the UPROPERTY() statement. Seems the Edit* ones affect the main editor and the Blueprint* ones affect the blueprint editor. It was always a bit confusing to me. I just used BlueprintReadWrite and EditAnywhere all the time. Glad I looked into it for you. Cheers.

more ▼

answered Dec 10 '17 at 02:27 AM

avatar image

4.4k 32 79 42

avatar image jr557 Dec 10 '17 at 02:49 AM

I tried but it didn't work for me. I even tried (EditAnywhere, BlueprintReadWrite, Category = Mesh) and it still won't let me use the W-E-R tools in the viewport. I set a static mesh and when I click it, it shows the yellow border but the tools are still grayed out.

avatar image Jin_VE Dec 10 '17 at 03:08 AM

Can you change the values manually in the Details window when you select it? You could try this: https://forums.unrealengine.com/development-discussion/content-creation/4520-transform-axis-disappeared.

avatar image jr557 Dec 10 '17 at 08:41 AM

Yup, I can change Relative Location, Relative Rotation, and Relative Scale 3D in the side window bar on the right. I'm having trouble finding those options but I found an option Editor Preferences - Level Editor - Viewports - Enable Combined Translate/Rotate Widget but checking it didn't seem to help.

avatar image jr557 Dec 10 '17 at 09:05 AM

Here is a screenshot of what my editor window looks like. You can see the "Relative" options on the right tab there but the W-E-R tools grayed out. alt text

sm-screenshot.png (455.5 kB)
avatar image Jin_VE Dec 10 '17 at 09:18 AM

Oh. That's because it's the root component. The root can't be rotated there because it's rotation is in the world. If you add sub-components to it, you will be able to rotate them relative to your mesh -- not that you want to, just that's how it works. In other words, the root component's rotation is the actor's rotation.

What you need is a "Default root node". I've never done that before but... In your class, add a Scene Component, call it "DefaultSceneRoot" cuz that's what the UE4 default name is. In your constructor, add "Root = DefaultSceneRoot". Then call "TestMesh->SetupAttachment(DefaultSceneRoot);"

I think that's how you do it.

avatar image jr557 Dec 10 '17 at 09:44 AM

That seemed to fix it, marking this as the answer. How do you usually create a basic actor with a static mesh without using the "default root node"? You said you've never done it this way before and I'm still learning the basics. :)

avatar image Jin_VE Dec 10 '17 at 10:03 AM

It's not a mesh thing. This is how it is for any component. If you need a component to be rotated independently from the actor then it can't be the root node. Similarly, if you call things like SetRelativeLocation() on a root component it will do the same thing as calling SetWorldLocation().

If all you have is a mesh then there's no reason to rotate it in the blueprint viewport. You can just plop or spawn the actor in the world and rotate the actor. The mesh will rotate along with it. So you don't really need a separate root object. You only need that if you want to rotate the mesh independently from whatever else is in the actor.

If you only need to orient the mesh so it's facing 'forward' then you can edit the mesh asset and change "Import Rotation", then select "Asset->Reimport ..." from the file menu.

Good luck with the rest of your endeavor.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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