Sprite rotation help

@Rune, I played Nine Cores. I wanted to learn how did you make the gun rotate using the mouse? I want to use that to make my own gun game called battlefront. I didn’t want to go into the project because it was too laggy.

Regards, RizeUpDev

2 Likes

Sorry I took awhile to respond, here’s how it works:

  1. I used the browser extension to get the mouses location, but then I had to do a little math to make it relative to camera. I placed a sprite on that position every frame as a cursor.
  2. I have another sprite for the gun, which is set to the players location every frame. I placed the gun art to the far right of the Sprite so that when it rotated it swiveled around the character.
  3. Then, I used a block in the Sprite Util extension to find the angle between the player and the cursor, and set that to the guns rotation.
  4. When it fired, I got the same angle and made a sprite to move in that angle using a different block in Sprite Util.

Hope this was helpful! If you want, you can look at the code in this, it should be less laggy.

6 Likes

Oh thanks! Now I can complete all of my other 21 pending projects!

1 Like