Page 1 of 1

Gun Help

PostPosted: Thu Jul 29, 2010 12:34 am
by Scorpion50o1
OK this version has Pistol, Machine Gun, ShotGun, and BattleRifle
[single shot, full auto, spread single shot, and burst]

Re: Gun Help

PostPosted: Thu Jul 29, 2010 2:54 am
by krenisis
Ok this is pretty good...its different from the tutorial i did but the shotgun is great coding. I think this is a good way but I do it differently. You should upload thec data file with the arial.ttf font. Since Iam a vetaran I just loaded up the font but most people will not know how to do that. Goodwork!!!

Re: Gun Help

PostPosted: Thu Jul 29, 2010 7:14 am
by DST
Okay this is not the best way to go about this. 1st, you should have only one bullet actor. Then make two global variables, shotangle and shotvelocity. Then, on bullet>createactor>

Code: Select all
angle=shotangle;
directional_velocity=shotvelocity;


And on the event to shoot bullets (which should be machine gun's event, not other's):
Code: Select all
shotangle=0;
shotvelocity=15;
CreateActor("bullet", "bullet", "no parent", "no path", width/2, 0, false); 


shotangle is a global variable, and each bullet will perform it's createactor as it's made, so you can then change shotangle and make new bullets, and they will all start with the last value shotangle was set to before their createactor() was called.
The width/2 is the width of the creator actor, in this case, gun. This will make bullets appear at (gun center+half gun width), or, at the far right side of gun.

To simplify, do this:

Code: Select all
int i;
int tempangle=5;   //the angle between shots
for(i=0; i<5; i++){      //do this 5 times
shotangle(10-(i*tempangle);  //(tempangle is 5, so shot 0 = 10; shot 1= 5; shot 2=0; shot3=355, shot4=350;)
shotvelocity=15;
CreateActor("bullet", "bullet", "no parent", "no path", width/2, 0, false);
}


Now if you want to make a different bullet animation, or speed (rockets may move slower), you only have one createactor() line to edit. Note that this loop code fires all five bullets at once. It could shoot 1000 bullets at once and the code wouldn't get any longer.


The way you have it, with all those bullet actors, is that each object that bullets collide with will need an event for every single bullet. Editing that is way too hard. You should definitely have only one bullet actor.