|Attention||Topic was automatically imported from the old Question2Answer platform.|
Hey! I’m building a Twin Stick shooter prototype for fun and learning.
Analog stick based movement with the left stick on my controller is working fine.
I’ve also got a little arrow sprite that is visible when the right stick is pressed, to show which direction you’re aiming. I’ve got this rotating in the direction the right stick is pointing just fine too.
The code for this looks like this:
if is_aiming(): #True if right stick is pressed in any direction. arrow.visible = true arrow.rotation = aim_direction.angle() #aim_direction is a normalized Vector2 else: arrow.visible = false
Now what I want to do next is get the arrow to offset itself from the player sprite by a standard distance in that same
aim_direction. But I can’t figure out how to do that.
Say I want the arrow sprite to display 16 pixels away from the player sprite in whatever direction the right stick is being held. How do I go about doing this? Can anyone point me in the right direction?