Hello to Everyone… ( ask you sorry for my english in advance )
my problem could be simple for you ( and i hope be )
I use a first person camera… and when i pick up an object it will appear in front on camera to be examined.
i use MOUSE_X axis ( from axis mapping - Input ) to controll the “YAW” and MOUSE_Y axis to controll the “PITCH”.
everything works great but…i want my object could turn ( pitch ) always in the direction of camera.
when my object turn on “yaw” the axis turn with it so…the pitch change direction too PIC2
maybe the pics can help…
i just want to be able to rotate ( pitch ) always in the camera direction ( like pic 1 )
thank you to everyone in advance
That would be toggling between local or global transforming.
i tried in both ways… same problem
Can you show us a screenshot of your BP setup?
You need to define your own axis as the cross product between the camera vector and world up (0,0,1). Then you need to instead perform a rotation on your axes as vectors around the newly defined axis. You will not be able to do what you want by using a rotator since by definition you are restricted to the 3 main axes of rotation.
Thank you Ryan, may i ask you if and where can i find some tutorial or forum about " create this vector axis "
i already can create a foward vector from camera…but i can’t create one vector crossing my camera vector
Thank you very much
Get cross product between the camera vector and world up (0,0,1). cameravector is campos-objectpos normalized.
There is a node called “Rotate Vector Around Axis”.
I had a quick go based on RyanB’s answer.
Swapped out RotateAroundAxis with the RotatorFromAxisAndAngle node. Seemed to work ok for me at least.
Hope that helps.
thank you eanandroid but dosen’t work for me ( same problem ) maybe can help you if i say that …
The blueprint is the PLAYER blueprint and the object i take in front of the camera is an EXTERNAL ACTOR…
i created a variable ( actor ) and i set the actor in accordance with what object I interact.
so… instead of GET WORLD LOCATION i have “GET ACTOR LOCATION”
i don’t know what can i do …
That is not the rotate note I was talking about. I am talking about “rotate vector around axis”. You need to supply it with a vector AND and axis. And you need to do three of them, one for the fwd vector, one for the left vector, one for the up vector.
The math you have going into your rotator is part of what you need for an axis. You also need to do cross product with (0,0,1) to create an axis that is perpendicular. Then you need to use that as the axis to rotate all 3 vectors and then make rotation from the vector axes.
may i ask you an example of blueprint screenshot of all operation?
I’m stuck from more than 1 month in this problem
i hope to don’t ask to much…
thank you so much
dont forget to read the node comments they explain the rest
Hello Ryan and hello to all …
I was really hoping to be able to write that everything was solved … but I can not.
I’ll show you what happen to me…
all work good but turn in a wrong axis.
another problem is…
I used an actor “INSIDE” my Player_blueprint for testing the Ryan’s solution…
you can see in this pic
PIATTO is the actor i tested for the Ryan’s Solution
but my intention is to use an EXTERNAL ACTOR so i created a variable ( ACTOR ) called OGGETTO_PRESO ( you can see in the previous pic )
and everytime this variable will be setted by " LINE TRACE BY CHANNEL - BREAK HIT RESULT - HIT ACTOR - "
but with ACTOR variable i can’t use " getworld…POSITION or ROTATION " i can use only " getactor…POSITION or RELATIVEPOSITION "
what can i use of those?
thank you so much… and sorry for bother you again
I don’t want GIVE UP…
i add also my blueprint pic…
Wow I did not know about that draw debug coordinate system node. I have been manually drawing all 3 lines every time I do this kind of thing.
Anyways, the GetPosition value from an actor variable should just work. Works perfectly fine here.
The selected actor is the BP that does the rotation stuff. The colorchart mesh is just a regular mesh in the world with no BP script:
Colorchart mesh is referenced by the other BP as actor reference:
Changing angle causes mesh reference to rotate around an axis perpendicular to the vector between the actors:
My script looks the same as yours:
i wrote this script inside my PLAYER_BLUEPRINT
is it correct?
and my “dish” mesh is inside a blueprint actor.
You need to debug to see what is going wrong at this point. Your math looks the same so something about your vectors or actor locations is not working as expeted. Do draw debug sphere on all your locations to make sure they are right.
Ok i found the problem…i used a normal " vector*vector " instead " CROSS PRODUCT " ( you can see from the pics i sent before… my have ADD PIN your NOT
Now work perfectly … i’ll check better for be sure.
So Ryan…what can i say… thank you so much for your help and time spent. You are so helpful.
oh man I feel your pain… those nodes are way too similar looking. I remember complaining about that a while but but not sure what happened to that bug report… Glad it is working now!