Announcement

Collapse
No announcement yet.

Quick question about ComposeTransforms

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

    Quick question about ComposeTransforms

    I have a transform for an actor, and I want to find a location of a point along the forward vector. In other words, I basically want to do the same functionality as AddActorLocalOffset to find a point in front of the transform, but without using an actual actor.

    I first tried using ComposeTransforms and AddTranslations, but while I can use it to find a point in front of the transform, it doesn't take into account the original transform's rotation. I'm assuming I need to do something with the rotator's forward vector?

    See this image for a visual of what I'm trying to do:

    https://answers.unity.com/storage/te...e-test-rig.jpg

    #2
    GetActorRotation().Vector() will return the unit vector facing in the rotation direction. Now you can apply vector algebra to uncover the world coordinates of the desired point (for instance adding component-by-component)!
    I don't understand the "without using actual actor" clause.
    https://ravimohan.net/
    https://github.com/ravimohan1991

    Comment


      #3
      Thanks for the reply, but I'm still not sure how to go about doing this. What I tried was basically this, when trying to find a point in front of a socket's transform:

      Code:
      FTransform objectTransform = MySkeleton->GetSocketTransform("MyBoneName", RTS_World);
      FVector rotatedDirection = objectTransform.Rotator().Vector();
      rotatedDirection.Y += 25;
      
      // Convert from local to world
      FVector worldVector = rotatedDirection+ objectTransform.GetLocation();
      However, the resulting worldVector does not take into account the bone's rotation, so the point isn't where I need it to be if the socket's rotation is anything other than zero.

      Comment


        #4
        Hmm, I don't have much experience with FTransform yet, but try scaling the rotatedDirection by some scalar (10 or something). Maybe the rotation is not differentiable with unit vectors. You can also try
        Code:
        FVector rotatedDirection = objectRransform->GetSocketRotation("MyBoneName").Vector();
        https://ravimohan.net/
        https://github.com/ravimohan1991

        Comment


          #5
          I did try using a scalar, but the results seemed even more off, but I can't exactly describe why. Getting the rotation vector from the socket as you suggested here also didn't seem to give correct results.

          Comment

          Working...
          X