Hi everybody.
Maybe it is a silly question or somebody else has asked before, but after some days i was unable to understand. I am writing a simulator (not really a game). I need to start my world controlling my player/pawn and, at some moment, i need to “detach” camera from player (preventing player from moving anymore) and attach to another element simulating such object point of view. I also need to do it only with c++.
In my AGameMode class i have:
MyGameMode::MyGameMode(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) {
PlayerControllerClass = MyPlayerController::StaticClass();
DefaultPawnClass = MyAvatar::StaticClass();
}
so i basically create a very simple skeleton with a controller (just to use arrow keys) and an avatar (without body).
In my class “MyAvatar” i have:
MyAvatar:: MyAvatar(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) {
MyCameraComponent = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("TopDownCamera"));
MyCameraComponent->AttachTo(RootComponent);
}
In my class “MyPlayerController” i do nothing special.
MyPlayerController::MyPlayerController(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) {
bShowMouseCursor = true;
}
When project start i can walk through my scene using left/right/top/down keys. What i want to do is (for example pressing “esc” key) to detach “MyCameraComponent” from MyAvatar and place it on another object.
Can someone help me in achieving such result?
Thanks everybody