Object rotation following cursor

I am trying to have the rotation of this ball follow the cursor. It can only rotate along the X axis as its a 2d game, and i am also looking to do the same with touch controls. I can get some rotation with Y and Z, but not X. I can’t for the life of me figure out why its not working.


I rotated the spring arm so the camera faces Y and got this to somewhat work. Problem now is that the ball spins back and forth instead of following the mouse if i circle around it. The ball debug also follows the cursor properly now, so I kinda feel more lost.

How do you want to interpret the cursor in 3d space? You want a) the ball to look at the wall behind it, the floor and over itself when mouse moves?.. Or b) rotate the object by dragging on the screen?

I guess option B would be the one. I only want it to be able to rotate on one axis. Imagine the ball is a rocket and the exhaust part of the rocket always points at where the cursor is or a finger on a screen touches. So the rotation should not be affected by whatever object might be on the screen.

I also tried to use “Get mouse position” but couldn’t get it to work.

Try this:

It won’t snap to the click location. Think it would be easy to adapt if that is the desired behaviour.

In theory it should work just fine with touch.

Let me know if you have any questions.