The Daily Click ::. Forums ::. Klik Coding Help ::. Rotating Gun that shoots?
 

Post Reply  Post Oekaki 
 

Posted By Message

kksonwhowho



Registered
  05/07/2009
Points
  719
17th July, 2009 at 23:46:20 -

I want to make it so the gun in my games rotates towards the my character and the gun shoots a bullet every 11 milliseconds. I have the rotating part down, but how do I make it shoot from the end of the gun? I have tried using shoot an object from the guns direction, but it only shoots to the east for some reason. Can someone please help.
Im using the rotating gun example by Jaffob which is here.

http://www.clickteam.com/epicenter/ubbthreads.php?ubb=download&Number=3942&filename=Application.mfa

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
18th July, 2009 at 01:57:14 -

When you use the built-in "Shoot Object" function, it uses the shooter object's "Direction", rather than it's "Angle".

Directions are what the built-in movements (racecar, bouncing ball, etc) use, and what you edit in the animation editor. However, there are only 32 "directions" in a circle, compared to well over 360 different angles (there are 360 degrees in a circle of course, but angles don't have to be whole numbers).
This means that rotation of objects using 32-directions appears jerky, and also that projectiles using built-in movements (incl. those fired using the built-in "Shoot Object" function) can be very inaccurate - especially over long distances.

Consequently, most of us us custom movements for such things. The example you have found does not change the "Direction" of the gun - only it's "Angle" (The angle relates to actual sprite rotation).

The easy option, would be to add a line that says:

* Every 11 milliseconds
-> Set Gun Direction to Gun Angle / 11.25
-> Shoot object from Gun action spot
(you should set the action spot to the end of the gun barrel, rather than the center of rotation, which is where the hot spot should be).

As I explained, this is far from ideal.
If you don't mind a small amount of added complexity, go here: http://www.create-games.com/article.asp?id=2129
Don't follow the advice in the article - instead scroll down to the comments and read them / download the example.
Also, read the first bit (smooth rotation) of this: http://www.create-games.com/article.asp?id=2120
Maybe take a look at the "Bullet Widget"...
There's a *lot* of info on "360 degree shooting" if you search


 
n/a

kksonwhowho



Registered
  05/07/2009
Points
  719
20th July, 2009 at 19:50:46 -

Thank you so much!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click