I try to set the rotation of a character by using SetActorRotation() but somehow this has no effect.
I disabled the controller rotation but that didnt help either
bUseControllerRotationRoll = false;
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
I made a workaround by rotating the character mesh instead but somehow I can’t replicate that to clients but on the server it works well
void ATOEUnit::SetUnitRotation_Implementation(FRotator newRotation)
when i log the actor rotation it’s always 0 which is odd.
Hope someone can help. Thanks
Relative Rotation rotates component inside of the actor. Actor rotation will still be zero, try reading component’s world rotation, then you should see proper value.
But did you used this on first try?
How can I read World Rotation? I only find SetWorldRotation?
Yeah set actor rotation was my first try but nothing happens when I use that
Ohh you are using character, my bad. I think you have to use controller rotation for them, take a look at this:
Hmm doesnt work. Maybe because I use an AI Controller? I set bUseControllerRotationYaw = true and tested it but it isn’t rotating at all now.
I just dont understand why set actor location doesnt work. When I blueprint my Character the (Self) Component doesnt even have a Transform.
SetActorRotation is a method of AActor class. ACharacter is a class two levels down from it, so SetActorRotation could have been overridden at least two times
in top of that it has CharacterMovementController, which can be doing it’s own thing as well. I would try from the start, to take a base ACharacter and check examples of code where people force characters to turn in a specific direction.
Maybe someone else knows what is going on, I haven’t use characters in C++
Ok I found a working solution… well it’s more a workaround but it does what it should.
I calculate the new rotation on the Server and store it in an replicated variable repRotation.
I then update the Mesh rotation since this is the only rotation that is working on all actors client and server
basically like this
I feel so stupid now… Rotating is handled by the movement component and when you call
you have to pass a Rotation and that rotation was always FRotator(0,0,0)… changing this to my valid rotation works perfectly and also has integrated replication
Ohh, that explains it
I had similar case with one blueprint.