• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Image angle with offsets [SOLVED]

Ax209

Member
Hi Guys. I'm sure this question has come up before but the programming is way beyond my capabilities and I can't search for it (I have tried) but I literally have no idea what to search for. Because I don't know the terms.

I have a gunship and I'd love to create instances at the end of the cannons. However the cannons move at an angle and that kinda puts a kink in what I wanna do. In order to prevent a poor explanation, I drew a picture.

I can make the bullets generate at a fixed angle but not when the guns turn. Well at least not through each cannon, they just appear out of the middle.

Any help much appreciated. :)
 

Attachments

Alexx

Member
You'd need to use:
Code:
lengthdir_x(len, dir);
and
Code:
lengthdir_y(len, dir);
Which can be confusing initially.

Try yourself first, but if you need an example, share your sprites and I'll knock one up.
 
Last edited:

NightFrost

Member
Commonly, lengthdir_x and lengthdir_y are used to find the x/y position of a spot whose angle and distance is known to you. Just add the rotation to the angle. Remember that zero degrees rotation in GM means facing towards right.
 

Ax209

Member
Guys you've been amazing. Took a while to have a look at examples and to apply the function to my own context but it worked wonderfully in the end. A great learning experience! Thanks so much!
 

Attachments

Top