June 2018
Beginner to intermediate
298 pages
7h 38m
English
The previous solution is acceptable, but there is another possibility. Instead of the arrow bouncing back and forth, you can aim by moving the mouse side-to-side. The benefit of this option is that you're not limited to 180 degrees of motion.
To accomplish this, you can make use of a particular input event: InputEventMouseMotion. This event occurs when the mouse moves, and returns with it a relative property representing how far the mouse moved in the previous frame. You can use this value to rotate the arrow by a small amount.
First, disable the arrow animation by removing the SET_ANGLE portion from _process(). Next, add the following code to _input():
func _input(event): if event is InputEventMouseMotion: if ...
Read now
Unlock full access