aligning actors with rotating weapons


  • Posts: 4
hello everyone, my name is SDK.

I've found Stencyl about a month ago, and have been working on a game. I started with literally zero experience making games, and its pretty amazing what I've been able to accomplish with this program.

I've hit a little bump in my first game and was wondering if anyone had any ideas that could help me out. So basically I've made a platform shooter, with rotating weapons. when I fire, a bullet is created, and also a muzzle flash. I've managed to align the bullets with the weapon fairly well, and the muzzle flash, as long as I'm aiming forward, if I aim up to far, or backwards, the weapon rotates, but the muzzle flash still spawns at the same x and y. I cant figure out how to make the x and y adjust, based on the angle of the weapons. I'll attach screen shots.

1. All good...

2. Not so much...

I've been struggling with this one for a few days... Any help would be appreciated greatly.


  • Posts: 4
I think I've actually got this thing figured out.

I created two attributes "X Offset" and "Y Offset"
And set them to...

Then when I fire my weapon, the muzzle flash is created like so...

Note, subtracting 70 from the x-center, and 45 from the y-center is just to adjust for the transparent pixels in my muzzle flash image.

Now as I rotate my weapon, and fire no matter where i point it, the flash is spawned near the tip of the gun.

If there's a better way of doing this I'm still interested in hearing.


  • *
  • Posts: 1260
The way you've done it seems correct.  It does become cumbersome trying to tweak the values especially if you have multiple different animations (walking, jumping, climbing) where the offsets would be different. 

Great graphics by the way, looking forward to playing this one.