To explain further, the player controls a sphere placed inside the base (his heart)
I don’t know if the problem is that the camera is inside the Blueprint pawn controlled by the player
I also tried using a widget to detect finger position on the screen but it also didn’t work.
first, your setup ,
you have a Blueprint Heart with inside a camera ,
and another actor called frame_blueprint that is the actoryou want to rotate
Correct?
You can correctly rotate the camera around the target .
set onl the mouse X to add a actor world rotation on the target, using the :
Rotation from axis - camera right vector.
now try to run the simulation and check from every possible angle, if the rotation applied
is always relative to the camera.
is the target rotating always the same ?
is the target rotating always different ?
is the target rotating relatively to the cam ?
If rotate in wrong direction you have to multiply the mouse axis value for -1
I just notice that you have 0,0,0 when you print the camera right vector, that not possible too !
if the camera exist , must have a orientation , and cant be 0,0,0 at least is 1,0,0
Lets split the problem
Try making a new clean blueprint, with a camera and print the mouse x and the camera vector right.
If you dont see values, there is something in the project that we must fix, or some other stuff like blueprint that absorb the events.
To be mega-sure make a new level and try there the new blueprint.
Ok, then inside the blueprint heart where the camera is, I find its values print on the screen with the camera Right Vector
But if I test with the mouse X of the same way, the value remains always at 0.
Maybe the problem comes from the fact that it’s a mobile game project and I do not have an Input Mouse from Set in the Project Settings ?
Because if instead of the “Mouse X” I use the “Get Input Touch State” in the level BluePrint, I correctly get the X and Y location of my input on the screen (and so of my mouse).
I have a standard project clean and neither i have set the mouse mapping.
But for me works fine
Anyway lets try to have this work,
Get yourself the difference between the mouse coordinates at every tick and apply the rotation like before but inputting you the value.
So
At every tick , get the input state x and y, subtract this value from the older xy, this is “value”
now add rotation world-make rotator from axis- pin in the “Value” .
Save the x y as old xy
Ok so, with this function, i get the coordinates of the mouse
But for the rest I have to admit that I’m a bit exceeding, can you explain to me with an example in picture because I’m really trying to understand but I’m lost.
is very simple, @Ptiflodu85
Now that you can see the mouse value, you have to identify the value of the motion.
as you can see from the print , the tick event run at 60-100 time for seconds
and he print all the positions 100,100, 102,100, 105,100…
what you want to do is understand of how much it change for every tick.
So when you start the movement, Maybe with the rightmousebutton
you create a variable to store the mouse position in that moment. “MouseStartPos”
Now in the tick event, you can understand of how much you moved by subtracting the new position to the old position of the mouse.
if was 100,100, and now is 120,80…
in this tick you moved of +20 x, -20y
if you did not move the mouse for some tick, the numbers wil be the same and the result is 0
so no rotation when you dont move.
Now you can apply the rotation with the make rotation from axis, using the camera and using this value X for rotate the base on z , and the value of y, to rotate the base on the other axis.
Do not forget that before the tick ends,
you must record the new mouse position as the “StartMousePos”
So the next tick will take on from there,
At each Tick, I subtract the current position of the mouse to its old position. And at the end of the tick i record the new position as the “MouseStartPos”
What should I do now with the camera knowing that I’m in LevelBlueprint and I can not get the Vector Right values from the camera that it’s in the BP_heart?
from level blueprint,
get a reference to your Bp_heart.
if you have only 1 BP of this kind you can use
get actor of class, to get a ref to him
With the ref at hand you can set the variable inside that actor or even call events.
if you have his reference in the form of an actor reference
than you can use “cast-to”- heart-bp
and by that , do the same.
So i would create a variable inside heart-bp
that contain a 2d vector , for value x and y
lets call it MouseMoved_xy
Level blueprint will constantly set the variable
inside that actor with the value you just calculated, so the subtraction of the positions of the mouse.
so now you can use this variable with the make rotation from axis and plug the mouseMoved_xy to the value
IT WORKS !!!
I finally managed to recover all the values in the Level Blueprint (Mouse Position, Vector Camera, the Object to rotate).
Thank you for your time and all explanations, may God bless you and your lineage.