Announcement

Collapse
No announcement yet.

Rotating for movement doesn't work quite right

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

    Rotating for movement doesn't work quite right

    I have a spaceship that moves through space. I want it to tilt one way when moving upwards and tilt the opposite way when moving down.

    This doesn't seem to go quite right. Look at this. The ship in it's neutral position:

    Click image for larger version

Name:	629b39b5c7.jpg
Views:	1
Size:	42.9 KB
ID:	1166569

    Now I press Down. The ship is now supposed to tilt towards the camera but look what happens:

    Click image for larger version

Name:	89b007fdd8.jpg
Views:	1
Size:	30.4 KB
ID:	1166570

    At this point it's half way to the next position it's going to be in and it didn't even start to flip over yet. When it gets to the bottom things start to get really weird:

    Click image for larger version

Name:	8b6557906e.jpg
Views:	1
Size:	38.0 KB
ID:	1166571

    The ship starts to tilt away from the camera and then this happens:

    Click image for larger version

Name:	0c5aa277be.jpg
Views:	1
Size:	56.2 KB
ID:	1166572

    It turns completely on the side so you can see the underside of it. From here the angle will keep being weird and it just keeps rotating oddly.
    When I move up instead it actually does the same until it reaches it's destination point in which it starts to rotate towards the screen and then decides to rotate away from the screen in that angle:

    Click image for larger version

Name:	ef6b6d033f.jpg
Views:	1
Size:	32.3 KB
ID:	1166573

    Click image for larger version

Name:	319092b41e.jpg
Views:	1
Size:	120.4 KB
ID:	1166574Click image for larger version

Name:	b186cf4853.jpg
Views:	1
Size:	118.3 KB
ID:	1166575Click image for larger version

Name:	8e07cce37c.jpg
Views:	1
Size:	105.1 KB
ID:	1166576Click image for larger version

Name:	b837b7cbc2.png
Views:	1
Size:	98.1 KB
ID:	1166577Click image for larger version

Name:	299f90cc57.png
Views:	1
Size:	104.9 KB
ID:	1166578

    #2
    Are you trying to rotate as long as a button is held for example, or rotate a set amount when a button is pressed and then rotate back?

    Unpopular Minion on the Play Store (Released: January 31, 2016)

    Comment


      #3
      Originally posted by Distul View Post
      Are you trying to rotate as long as a button is held for example, or rotate a set amount when a button is pressed and then rotate back?
      The latter

      Comment


        #4
        The way I did it for arcade airplane is to have a two bodies used for different part of animation. The root of airplane is invisible sphere object which can only yaw and pitch. To the root I attach airplane fuselage and only fuselage is allowed to bank. By attachment I mean simply parenting fuselage component to the root component in blueprint. This way you avoid all of issues with gimbal lock.
        Youtube Channel

        Comment


          #5
          To illustrate it:
          Click image for larger version

Name:	AirplaneHierarchy.JPG
Views:	1
Size:	18.6 KB
ID:	1092948
          So if I want aiplane to gain or drop altitude by banking, then I rotate Root. When it need to turn left or right, I just turn Root by yaw and Fuselage by roll. This way you get illusion that it turns like a real airplane but animation logic doesn't need to be aware about how pitch and yaw have to handled when you roll object by 90 degrees and get gimbal lock.
          Youtube Channel

          Comment


            #6
            But now I see that your problem is most likely not a gimbal lock but the update logic. For Lerp(rotator) to actually work it needs to be called again and again. So your MoveShip even should be called as long as your Timeline should be running.
            The next issue is that you are Lerping not from original state to target state but from current state to target state. On every calculation of Lerp, rotation of your actor changes and you are plugin changed rotation as parameter (GetActorRotation->CurrentRotation) into Lerp. Instead, you need to save your default rotation somewhere and use it in Lerp, without overwriting it with each Lerp calculation. I hope it's clear enough.
            Youtube Channel

            Comment


              #7
              I guess I fixed it.



              Click image for larger version

Name:	f9959f3f2d.jpg
Views:	1
Size:	41.3 KB
ID:	1092950Click image for larger version

Name:	a229b4bb60.jpg
Views:	1
Size:	114.7 KB
ID:	1092951Click image for larger version

Name:	ce7aed41ec.jpg
Views:	1
Size:	98.3 KB
ID:	1092952

              Comment


                #8
                Does it get all wonky if you mash the buttons? Might be something to check as that may be a problem.

                Unpopular Minion on the Play Store (Released: January 31, 2016)

                Comment


                  #9
                  You can't mash the buttons.

                  Comment

                  Working...
                  X