How do firearms work in UE4?

Hello, I would like to know how to create mechanics, for example to integrate ammunition plus a weapon, then eject a shell and a projectile.

For example ammunition, should I create a single model + projectile case and have them separate in the shot, or one an entire ammunition then a separate case and projectile?

I’ve never done a type system, that fills me with doubts.

You think too much realistically :stuck_out_tongue: As a devloper you are director and magicsion, it does not matter how you do it things, all it matters is what player see. Does player see the bullet with case in weapon? If not then whats the point of separateing something that they don’t see, just spawn bullet from front of gun and case on the side (that could be particle). Even if they see bullet in gun you can make it animation in part of what they can see and hide it somewhere and still spawn buttlet and case.

Note that lot of game don’t even do bullets and just do line tracing, because normaly human don’t see bullet traveling in the air as it simply too fast, or else they want to make it realistic or do some slomo mechanics

it’s not quite what I meant, what I mean is how to integrate mechanics, for example: the player will have to reload his weapon at some point, assuming that I make this animation of the player taking the bolt the straight guard, (in this part the loader will have to stop making part of the gun and get thrown on the ground, then how to do it?) after picking up another charger and putting, each shot of the weapon she will throw the case out of the gun’s chamber , these kits will have to be part of the scene and have their own physics like: roll, kinetic etc …

Are you familiar with Animation State Machines? It is where you should begin.

Thank you, I did not know that.

Hey there, it really depends on the complexity you want to achieve. In my game i fire actual projectiles (and dont use line traces) because i want to take into account the gravity drop, ricochet, etc. To do ejecting bullets i used a particle system and i do a anim notify to spawn that particle system in a specific frame of the fire animation, like the muzzle flash and smoke. For the ammo clip it would be part of the weapon and taken out using the animation, but at some point (ideally outside of the players fov) you would swap it by a clip actor that would have physics simulation and drop to the floor.

Ok, so you make the projectile and case apart, but how do you turn the static mesh of animation into actors?

For the projectile it’s just a normal actor with a projectile movement component and you spawn it on a specific moment in the fire animation. For the ammo clip it’s kind of the same, you have an actor with a static mesh of just the case and you enable simulate physics and spawn it on a specific movement in the reload animation. You can look into anim notifies to do that.

This post I did to remedy the doubts I was having to construct a gun asset, note the 7.62 x 51mm ammunition that I was doing below:

I will want to use this asset for other weapons, so I create the shell and the projectile separately or a single mesh? And if separately how do I unreal get the parts of the bag separately during the animation and become actors?

http://prntscr.com/hv68gh

Its not showing any image.

https://prnt.sc/hv68gh

Pelo nick falas português/brasileiro?

Eu sou português, por isso se calhar é melhor falarmos português. Podes-me explicar exactamente o que queres fazer? Porque a tradução que ele fez fica um pouco confuso.

I not speak english, i am braziliam, i use google translate

Bom, basicamente quero entender como fazer uma arma funcional na engine, começando pela munição, como projétil e estojo são coisas separadas fico em duvida se faço duas malhas separadas ou se eu pego um cilindro e faço a munição inteira a partir dele.

Depois, o projétil deve ser utilizado para outras armas, e também como o estojo tem que sair da arma como fazer essa animação de forma que ela assuma física na engine.

e outra, como fazer animações de recarga tiro etc? por exemplo temos NPCs, e jogadores reais em um jogo, então como fazer eles por exemplo: pegar uma arma no chão carregar e etc de modo que pareça natural?

Da forma como eu fiz o carregador faz parte da malha da arma (para ser usado na animação de reload), mas também precisas de uma malha à parte só com o carregador (que é o ator que é deitado para o chão). Quanto ao projectil isso é uma blueprint propria em que tens o projectile movement component e a malha da bala em si. As capsulas das balas que são ejectadas eu fiz como um objecto separado, ou seja, o projectil tem o aspecto da bala com ponta, as capsulas usam um modelo de bala sem ponta, a ejeção pode ser feita por particle system ou entao crias um actor e metes a simular fisica e adicionas uma impulso lateral para ela sair para o lado. O parecer natural tem mto a ver como as animações são feitas, ai não te posso ajudar mto pk isso é do campo da animação.

Se importa de me massar algum meio de contato, para mim entrar em contato?

Eu mandei-te uma mensagem privada no forum.