How to get a Angular Motor current orientation using blueprint?
Hi, I am looking for a way to get the current orientation of a Angular Motor. Thanks in advance for any help!
Basically when looking both in the inspector and in the blueprints I cannot find the current orientation of an angular motor. I need this value as I wish to control a joint and have a copy of this joint somewhere else attempting to reach the same angle every frames.
Ill try to explain a bit more with this picture of my setup. Ok so both the white-blue and the red-yellow joints are the same except they have different color. Their limits are the same but one will be using the "Target Orientation" variable in order to reflect the the angle of the other.
By example right now the red and yellow joint is controlled by the player as a somewhat ragdoll joint. This joint does not use the angular motor. The white and blue joint though is using the angular motor but needs to know the desired "Target Orientation" in order to use force to attempt to have the same angle as the red and yellow joint.
I did attempt to find the angle by myself like below but the problem here is that I am first really bad with that angle stuff and my calculation seems wrong but the main issue is that I might have to deal with angles greater then 180 degrees. Basically if the angle can be larger then 180 degrees there is no point attempting to calculate it using 3 points method since it will pull out the shorter angle that is less then 180 thus incorrect...
asked Nov 16 '18 at 12:49 AM in Blueprint Scripting
After several hours of messing around I realized that my first option was the best I just had to tweak it. Basically no i dont think it is possible to get the current angle as I wanted but we can get really close to it. It's just overly complicated..
Step1: Set up the pivot the way you want it with limitations but make sure that the angular limits are using a swing limit value below 180 degrees to get accurate reads, this is because there are no way for me to figure when an angle passes over 180 degrees and when this happens it will return 360-yourAngle instead...
Step2: Position the object to rotate along the axis and create a new actor (place it in the hierarchy of the object that will not rotate) and set its location along the axis with the object to rotate but make sure that it's position reflects the position of the object to rotate when it is in the maximum angle that you desire.
Now jump in the blueprint
Step3: Get the constraint location and the location of the object to rotate to make a direction.
Step4: Make a direction from the constraint location to the new actor that serve only to this purpous
Step5: From those 2 direction we can get the angle that we have been looking for yayyy !!! (remember no value above 180 though)
Step6: Since the Angular Limits have a swing limit to respect but that swing limit is basically 50/100 swing left and 50/100 swing right we need to take this in consideration when calculating our angle.
Step7: You feel like me that this was a sloppy job and you dont feel like testing 20 time by moving the empty actor around well do like me and add an extra variable that you can tweak by example (-40 , -23 , 0 , 50...) and it will help you to get the accuracy missing if there is any!
At this point I almost hope there are no better options as I am just tired of this problem and I am done! Here is my code, enjoy it and best of luck on your project if you have this issue.
answered Nov 17 '18 at 04:51 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here