How to move an object that is linked to a physics constraint by detecting a mouse movement?

Hello, recently i made a character with a sword that is rotating around him on Y axis

and now i want to implement a code that makes the sword move(still on y axis) from one side to another according to the player mouse movement, kinda like in a 2d game called ‘‘deepest sword’’.

for now this is my script

unfortunately it doesnt work, thanks for the help beforehand

hi @aki_kt

I dont know deepest sword but ive just watched a youtube video on it.

So am i right saying you basically want the sword to aim at the mouse by rotating around the Y axis?

Otherwise I’m unclear what you are trying to achieve sorry.

in ideal yes, it is indeed what i want . if its possible of course

But there is no need for the sword tip to look directly at the mouse cursor position, but if there is the way to accomplish that i will definetely implement it
A video of a possible way to implement it, unfortunately a lot of helping links has been outdated or straightup removed from this piece of gold in the hay

Also there is an option this in my mind, just letting mouse movements control the float variable that will either go positive or negative depending on the mouse position of screen.
Not follow, just increase or decrease the values by inputting mouse movement data

Check this out:

If you switch around the GetActorRotation to X & Z and the FindLookAtRotation to just Y, would that work?

I checked and it is a very helping thread, but notice that my sword is not an actor, its just a mesh, will it work if i reference it instead of an actor?

it just acts like this

You could i guess target the mesh but it would be easier placing the sword into a blueprint actor and using that example as a reference, it shouldn’t change how you are using it in anyway and adds extra functionality later if you need it to.

Can you show the mouse cursor so i can see whats happening in relation to the mouse position. also check that collisions are set to none if it is getting stuck, unless of course you need it to ?