Changing specific Static Mesh location

I’m new to Unreal Engine development and I’m struggling to do something which would be trivial in Unity.

I’m following this tutorial: [Unreal Engine 5 Tutorial for Beginners: Getting Started | raywenderlich.com][1]

I’m trying to do the “Rotating the propeller” section without the use of Blueprint nodes.

The Blueprint nodes can reference the static meshes individually but I can’t find any C++ method that would do the same thing. All examples I found online make use of acquiring the actor through a component and rotating the actor. This way, it would rotate the whole submarine and not just the propeller as intended.

Like this (Snippet from an ActorComponent code):

RotationTime += DeltaTime;
RotationTime = fmin(RotationTime, TimeToRotate);
auto actor = GetOwner();
float alpha = RotationTime / TimeToRotate;
FRotator rotator = FMath::Lerp(FRotator(0, 0, 0), FRotator(0, 90, 0), alpha);
actor->SetActorRotation(rotator);

In Unity this can be accomplished by declaring a GameObject in the component and modifying its transform. How can I achieve this in Unreal? I’m composing the static meshes in a Blueprint Class and I can modify their transforms in the Blueprint editor and they show up correctly in the game. I saw in a video tutorial that this would be a good case for using animations but I don’t see the reason why something so simple can’t be done strictly in code.

Hey @caiocsabino! Welcome to the Forums!

A few questions to get started:

  • Is the mesh you are working is part of a group of static meshes? And you are needing help finding that particular component in that blueprint to rotate, right?
  • Would you mind showing the effect you have going so far, as well as the details of the mesh in particular? Screenshots if you can.
  • Have you attempted to create a “propellor actor” inside of your blueprint to attach your script to and control rotation for that particular piece?

Any additional information you can provide will be a big help in solving your problem!

Thanks for your answer @Quetzalcodename !

  • “Is the mesh you are working is part of a group of static meshes? And you are needing help finding that particular component in that blueprint to rotate, right?” Yes, precisely

  • "Would you mind showing the effect you have going so far, as well as the details of the mesh in particular? Screenshots if you can. ". I’m attaching a screenshot which shows the static meshes in the Blueprint. The current achieved effect so far is that the whole actor rotates around the Y Axis (Code in original post had a 90 degree angle instead of 360 as it should be). Screenshot below:

  • "Have you attempted to create a “propellor actor” inside of your blueprint to attach your script to and control rotation for that particular piece? " This sounds more like what I want to achieve indeed. In Unity I can nest GameObjects and reference them on code. I couldn’t find how to put an actor inside of another one in a Blueprint. Do you have a working example I can check?

Thanks again!

Hey @caiocsabino!

So what you are wanting to do here is add a rotating actor movement component to your desired mesh inside of your blueprint. Here is a basic non-Epic affiliated overview of what that looks like and what it does:

WTF Is? Rotating Movement Actor Component in Unreal Engine 4 ( UE4 )

You can create your own custom C++ component for doing so as well. More information on that specific class can be found here:

I hope the above solution works for you!

Thanks!

This indeed will do for the example I posted. My focus is not necessarily in rotation per se, but rather how could I change the transform of another object inside the Root Component and how I would reference it by code.

I’m going to check how that component does that.

Cheers,