Understanding the code of rotating the door

The following code:

void UOpenDoor::BeginPlay()

// Find the owing actor
===> AActor* Owner = GetOwner();

// Create a rotator
FRotator NewRotation = FRotator(0.f, -60.f, 0.f);

// Set the door rotation
===> Owner->SetActorRotation(NewRotation);


The two lines that have ===> prior to them, will someone please explain to me what does it mean ? most of the time I am slow with understanding codes and need someone to treat me like a baby with it, if someone would explain them that would be great.

Thank you.

AActor* Owner = GetOwner();

Here we are creating a pointer to an AActor and initialising it to what GetOwner() returns (The AActor that owns this AActorComponent) So say we have this Bluprint comprised of something like

- BP_Door (Self)
|- StaticMeshComponent (Door Mesh)
|- OpenDoorComponent

GetOwner would get us the BP_Door Actor


This just calls SetActorRotation on that Actor and passes it the value NewRotation

So we created a pointer to the address of the door, then we got inside the value of the door and changed its NewRotation ?
Sorry as wrote before I am very slow with codes.

if by[quote=“XaiaT, post:3, topic:21978”]
then we got inside the value of the door
you mean accessed the contents of the pointer and called SetActorRotation with the new rotation then yes.

Well then thank you, thank you for understanding where i come from (y)

  1. (The AActor that owns this AActorComponent) how contain (or own) AActor the AActorComponent they is not derived or base each other?

class ENGINE_API UActorComponent : public UObject, public IInterface_AssetUserData
it’s order of UActorComponent class
2. we create the class OpenDoor which is derived form UActorComponent . AActorComponent and UActorComponent is the same?

No, that was a mistake. That should say UActorComponent not AActorComponent.

Yes AActorComponent is not UActorComponent but I am interested in how this classes connected each other? UActorComponent, AActorComponent and AActor

We created an Actor Component as Ben told (OpenDoor or PositionReport) but our new class is derived from UActorComponent how can OpenDoor class recognize AAcotr class?

I find one File:

there are only mention together classes AActor and UActorComponent

I don’t know it has or not any meaning

Because you are attaching a component to an actor you are setting that actor as the owner.

In Summary:

we created class OpenDoor which was attached to Actor class by this order:
AActor Owner = GetOwner();*
on the other hand Actor class contain all information (location, rotation and so on) about static mash (chair door, rock and so on)

and the OpenDoor class is connected the Door (static Mash) because it’s name is given here:

am i rigth?

You added it to that actor with “Add Component”, yes.

Do you mean that with “Add Component” we added new class(OpenDoor and PositionReport) in ActorComponent class?

No, in the editor. The green button in your screenshot.

what do you mean under the actor?
In my opinion with the green button “Add Component” we create new class and added it in ActorComponent class

is my opinion right?

No, you created the PoisitonReport class and selected UActorComponent as the base class. You then added the PositionReport component to actors in the world.

ahhaa! with the green button “Add Component” we added it (OpeenDoor and PositonReport) to actors in the world? is not it?


thank you

and is there any map how we take appropriate class and function for doing something example:

AActor Owner = GetOwner();*
apart from this order we get all information about our door Mash. AActor and GetOwne() is appropriate class and function

and if I want to do something different why and how I can search appropriate class and function is there any map for this?

Could you give an example of what you mean?

if it’s possible I want to know how can i use Unreal class structure flexibly.
I am beginner and if i want to do something how can i guess which class apply to or which function call?

AActor Owner = GetOwner()
with out the lecture i could not write this code because i would not know anything about AActor class or GetOwner() function.

if i want to do something myself how can i guess which class and function call from Unreal class structure?
there is only fortune-telling for this or is there more powerful tool?

Privacy & Terms