Archived

This topic is now archived and is closed to further replies.

DevLiquidKnight

Best way to make a simple 3d Bullet system?

Recommended Posts

My current bullet system sucks and I was wondering if anyone had any pointers on how to make like bullets that fire constnatly.. Currently I have a delay and im reusing bullet objects as an array and it is not really all that good was hoping to find a better way to implement this Id also like to find a better way to calculate the ray in front of user the bullet will travel. If anyone has any info on how to make good forms of this type of think plz post a link or some information or something

Share this post


Link to post
Share on other sites
there are nothing magical about bullets they''re just projectiles, that you can simplify as particles. have a stack of bullets (ring buffer probably), or a dynamic list, or to over-simplify, like in quake3, fire a ray and see if nothing''s hit. If yo tell us what yo udon;t like in the current system (which looks fine to me).

Share this post


Link to post
Share on other sites
I don''t really know what you mean when you say you want bullets to fire constantly and that you''re re-using bullet objects as an array, so I''ll just tell you how I would make the bullet system.

Whenever the fire button is down, you should call a FireBullet() function, the FireBullet() function should basically create a new bullet object (I mean C++ object, not 3d model object) and push it into an appropriate linked list. I don''t know, but I''m assuming you''re not currently using a linked list, and so that makes me assume you don''t know what one is or how to use one. Linked lists are basically lists of objects, and each object has a pointer to the next object in the list and the previous object in the list. Some even have pointers to parent nodes and child nodes. So basically you can write functions for them that add new objects to the list and delete ones from the list, so it''s like a dynamic array. My explaination is pretty poor, if you want to know more just do a Google search, and I think there are a few articles on this site about them.

Now, in my game, every object in the game would be a derivative of a basic node class, I''ll call it CNode. The CNode class has all the stuff a node in a linked list should have, like the pointers and the recursive functions to update each node in the list. The update functions, etc. would be overloaded in derived classes, so each class could have it''s own special update code and such. The bullets should just go in a straight line. Their movement vector should basically be the bullets speed, with a direction equal to the direction the gun was pointing when you fired the bullet. The rest is just collision detection and stuff.

Hmm, I had a lot to say in there that I tried to crush into as little writing as possible, so if you have any questions or need clarification just ask.

Share this post


Link to post
Share on other sites