Mouse Movement using a Motor

Hey, I’m trying to achieve on my motor6d, to change to the desiredangle using the mouse, for example, if i move my mouse to the left, the DesiredAngle will move to the left.

I’ve also asked several programmers who can do this type of stuff, and fail to see how to do it.

If possible, could someone help me out here? I am also confused with this.

Enjoy your day.


The easiest way to do this would be to just directly use the mouse’s 2d position on the screen.

Refer to this article:

By using the “normalizedPosition”, we can use the normalized x coordinate of the mouse to determine if it is on the left, right, or center of the screen.

Then, for example, you could linearly map mouse’s x-coordinate to steering angle.

max_steering_angle = 45
steering_angle = max_steering_angle * 2 * (normalizedPosition.x - 0.5)

If you want the wheel to actually follow where your mouse is pointing in 3d-space, it gets a little more complicated. But for someone starting out and looking for something that will just work, this is acceptable.

1 Like

Hey thank you, it does work now.