Hello,
Does anyone knows what determines the rotation of a newly possessed pawn ?
My APlayerController has a defaultpawn (first person control) has a function to possess some other ACharacter (third person control).
I always want to keep the point of view of the DefaultPawn, whatever other pawn is possessed.
I do this with a server side RPC (defined in my playercontroller.cpp):
void AyagPlayerController::ControlPawn_Implementation(APawn* TracedCharacter)
{
if (Role == ROLE_Authority)
{
Possess(TracedCharacter);
SetViewTarget(DefaultPawn);
AttachToPawn(DefaultPawn);
}
}
Both the DefaultPawn and the TracedCharacter are replicated.
here is the problem: as soon as i fire the possess event, the newly possessed character seems to align itself with the default pawn.
Capture 1 is just before the possession, capture 2 just after. No move has been done between the two captures, i just left-clicked to possess.
before:
After:
Wherever i am, the possessed pawn instantaneously reorients itself and shows me its back.
The fun thing is this instant rotation happens only on the clients. On the (listening) server, everything works as intended.
I have tried to play with various options/functions (server side / client side) i could find in the c++ doc such as:
SetViewTarget()
AttachToPawn()
bAttachToPawn = false;
bAutoManageActiveCameraTarget = false;
I couldn’t find any working combo and the result of my various tests seemed sometimes crazy (just implying that i am not understanding). For exemple, even with bAutoManageActiveCameraTarget = false in the constructor, the call to possess puts the view on the possessed pawn if i don’t call the SetViewTarget(DefaultPawn) to make things right.
The truth is i don’t understand in details what is going on during possession (what about the location/rotation of pawns and controller ?) so I am just trying everything blindly but no luck so far.
Any help appreciated.
Thanks
Cedric