I don't know if this is really the right place to put this thread but I have to ask; How do guns expel casings in games? Do they spawn a separate object every time the weapon fires or are the guns and bullets a single object with an animset?
depends on the game really, I've seen games that spawns actual casings that fly out with proper physics. And others that just have some that are part of the animation that just flies off screen and gets re-used.
We use a tagged position on the mesh in the form of a bone, so that the position is always correct no matter where the model happens to be. Same for muzzle flashes, attachments, lights etc. Then we spawn a model at this location. We use higher poly models for very, very up close detail as we are a first person game, and then waaaaaaaaaaaaaaaaaay lower LODS as you get further away. This way, they spawn from the ejection port and then fall to the floor in one movement.
+1 odium
You can recycle them too. Just store them at array and pull unused copy from it in new location. Alternatievlly you can combine meshes at firing location to one mesh after their velocity is zero and rigid body fall to sleep. This way shitload of them can be anywhere. You can also fake ones that are on ground with sprites When explosion is in place, load stored positions of combined meshes, pull free shells from cache and reactivate physic again.
Thanks everyone I was modeling my first automatic weapon and ran into the problem of not being able to reuse the previous bullet because I couldn't find a way not to use tween between the first and second shot, I solved it by creating the actual number of bullets inside the gun and that created the problem of having to find a way to separate them. Its good to know that games don't have a problem like this because they are just creating entirely new meshes.
Replies
You can recycle them too. Just store them at array and pull unused copy from it in new location. Alternatievlly you can combine meshes at firing location to one mesh after their velocity is zero and rigid body fall to sleep. This way shitload of them can be anywhere. You can also fake ones that are on ground with sprites When explosion is in place, load stored positions of combined meshes, pull free shells from cache and reactivate physic again.