Announcement

Collapse
No announcement yet.

Problem with FRotator functions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with FRotator functions

    Hi, I am making an Aircraft Simulator. I am facing a lot of problem with FRotator calculations.

    To avoid gimbal lock when adding FRotators, I used this
    Code:
    		FRotator CurrentRot = GetActorRotation();
    		FTransform RTrans(CurrentRot);
    		RTrans.ConcatenateRotation(NewRot.Quaternion());
    		SetActorRotation(RTrans.Rotator());
    This works ok but there is a slight jerking action when the actor hits the gimbal lock and skips over it.

    Oher than that, sometimes I want to change the Roll of the Aircraft when the Yaw changes(giving an tilting action when going sides). But when I change both at the same time, the pitch also changes.

    Should I rewrite the whole system using Quaternion? Will that work?

    #2
    Originally posted by envenger View Post
    Should I rewrite the whole system using Quaternion? Will that work?
    Yes it will

    As the person who wrote the code you are posting above I can verify that STATEMENT REVISED, see here:
    https://forums.unrealengine.com/show...l=1#post170690


    In my own multiplayer game which uses physics based skeletal mesh creatures as the playable unit, I found there is an additional issue with FRotator lockups, they happen even more frequently on clients than on the server!


    I was getting by with FRotator until I started testing multiplayer, and then I realized I just had to go the Quaternion route.

    Is your main unit a skeletal mesh?

    Is it simulating physics or not?

    ~~~

    Spherical Interpolation

    I can highly recommend Slerp for your needs

    Code:
    //Quat.h
    
    /** Spherical interpolation. Will correct alignment. Output is not normalized. */
    
    static CORE_API FQuat Slerp( const FQuat &Quat1,const FQuat &Quat2, float Slerp );
    My own game's development continues happily because I was able to make the switch to quaternion and all the lockup issues disappeared, even in multiplayer with multiple clients all tested on the same machine!

    Rama
    Last edited by Rama; 10-27-2014, 08:42 PM.
    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    ♥ Rama

    Comment


      #3
      Thanks for the reply Rama.

      Yup the code which I wrote was written by you https://answers.unrealengine.com/que...-rotators.html.
      It worked in nearly every case after that. But when making something which was needed to have much more rotational freedom like the aircraft simulator, it didn't work perfectly.

      I was confused if to use rotation matrices or quats.
      I have never used quaternions. Lets see how it works out.

      Edit.. Did you replace the FRotator replication by a custom quat replication?
      Last edited by envenger; 10-21-2014, 05:26 PM.

      Comment


        #4
        Originally posted by envenger View Post
        Edit.. Did you replace the FRotator replication by a custom quat replication?
        You can send FQuat over the network

        Code:
        UFUNCTION(reliable, server, WithValidation)
        void SERVER_SetGoalRotation(FQuat NewRot);
        If you get a crash related to this though, make sure to set it to a local var before sending it into the Server function:

        Answerhub
        https://answers.unrealengine.com/que...etting-it.html



        Rama
        UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

        ♥ Rama

        Comment

        Working...
        X