Announcement

Collapse
No announcement yet.

Rotate Velocity

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

    Rotate Velocity

    Ive got two, lets call them portals, when something touches one it gets sent to the other, it maintains its velocity pretty well, but it always comes out in the same world velocity it went in, which can cause a problem when two portals are side by side and entering one causes repeated flying into the other. Basically i just want to translate the old velocity and launch the player with the same velocity but on the x of the portal. Sorry for the wording, ive been at this for hours and im tired. If you need more info ill provide anything

    #2
    Hello,
    Have you try to get the rotation of your destination portal, apply it to your character (set rotation) and then set location ?

    Comment


      #3
      If you have both normal vectors for both portals.

      1 - get length of incoming (first portal) velocity vector

      2 - normalize vector of second portal

      3 - multiply normalized vector from second portal by length you got from first.

      But thinking more you probably want to maintain relative speed vector from first portal to second.

      "Vector A" = "Normal Vector of portal A" - "player incoming vector at portal A"

      "Result Vector" = "Normal Vector of portal B" + "Vector A"

      That is done in local space of both portals.

      to get it all working in world space, before all vector math translate player incomming vector to local space of portal A
      The after vector math and before applying player speed again translate "result vector" to portal B local space.
      I do not remember node names now for those translations. I am also afraid you need to do some rotation + vector math because there may be no node to simply translate.

      Comment


        #4
        second thought, i did something wrong and its broken again. I just need to keep the players speed, and totally change its direction, right now the player successfully moves to the new location and takes the forward rotation of the second portal so hes facing the right way, but he keeps the momentum from the first portal entry and flys like sideways or sometimes right back into the portal. you were definitely onto something with what you said previously but i did it wrong i guess, cause it was half working, and now its just not working. Is there any way i could just use the vector length and just apply any and all speed to the forward vector of the second portal
        Last edited by Reactant; 11-13-2014, 04:13 PM. Reason: im an idiot

        Comment


          #5
          Yes I wrote in first part how to copy vector over:

          math part:

          Normalize second portal vector,
          Get length of player velocity vector in first portal
          multiply length by normalized vector from second portal, put it into result vector variable

          physics part:
          after player is in new portal place, stop pawn, (there may be node to do this), or set velocity to 0.
          rotate it correctly
          add impulse ( result vector variable)

          And watch for mixing local vector space with world vectors. use one of them do not mix both without adjusting.

          Comment


            #6
            wicked you are a physics lord over the dominion of mathless noobs, one question i get funky behavior when the player isnt jumping, is this because isfalling +false? any ideas to fix this

            Comment


              #7
              Originally posted by nawrot View Post
              yes i wrote in first part how to copy vector over:

              Math part:

              Normalize second portal vector,
              get length of player velocity vector in first portal
              multiply length by normalized vector from second portal, put it into result vector variable

              physics part:
              After player is in new portal place, stop pawn, (there may be node to do this), or set velocity to 0.
              Rotate it correctly
              add impulse ( result vector variable)

              and watch for mixing local vector space with world vectors. Use one of them do not mix both without adjusting.
              thank you!!! This fixed it for me too )))))))))))))))))))

              Comment

              Working...
              X