-
Shooting Gun
Does anyone know how to make a gun which rotates according to the angle of the mouse and shoots laser when the mouse clicks?(in the mouse direction)
I made a basic platform game according to the tutorial. I was thinking of advancing it to a better sort.
Regards,
Tongxn
-
-
There is about 400 tutorials for this type of stuff. Pretty much you use atan2, cos and sin. I suggest you use google or search the tutorials on flashkit.
By the way, your sig isnt correct syntax wise.
-
NO honisty i don't want a smart remark, I need a real solution. And anyway I have no idea how do you make a laser shoot towards the mouse position
-
That wasnt a smart remark, it was a true remark. Here are just an example of relevant tutorials on flashKit:
http://www.flashkit.com/tutorials/Ga...u-81/index.php
http://www.flashkit.com/tutorials/Ga...u-80/index.php
http://www.flashkit.com/tutorials/Ga...u-79/index.php
http://www.flashkit.com/tutorials/Ga...-598/index.php
http://www.flashkit.com/tutorials/Ga...-611/index.php
http://www.flashkit.com/tutorials/Ma...1014/index.php
Here is a quick search on google for the math involved:
http://abe.www.ecn.purdue.edu/~agen215/trig.html
http://tutorial.math.lamar.edu/AllBr...aTrigIntro.asp
If you are past grade 9 you should know what sin cos and tan do.
None of the tutorials cover everything you want but if you read them you will be able to make it work.
The only part that I will comment on is the "finding the angle of the mouse". Most of the tutorials are way overcomplicated and one solution even freezes the computer under certain circumstances so just use Math.atan2 (y distance from point to mouse, x distance from point to mouse).
Just remember the Math functions output everything in radians and need all input values in radians.