I have an object which I want to rotate between -45 and 45 degrees, but I want that to be based on the mouse position. If the mouse position is at zero, I want the object to be at -45 degrees. If the mouse position is at the stageWidth, I want the object to be at 45 degrees. How would I accomplish this?
Share
Ignoring the “random” bit of your title, which seems not to apply to the actual question:
If you want to limit it, you can use min and max:
or conditionals like this:
or you can restrict the x value to the range (0 to stageWidth) before doing the translation.