Hi friends,
I’m making FPS game, and I’m using projectile based damage system, where the enemy gets damage when being overlapped (he has collision boxes for the limbs and body and sphere for the head) by the projectile. But I see that not every time I hit the enemy he gets damage. I’m using line trace by channel, and I can see the trajectory of my projectiles, they go straight trough him without doing any damage and in the next moment they do damage like they should. Can anybody suggest me a 100% sure damage system, so every time I hit the enemy he gets damage? Thank you!
Actually the line trace damage works very well. I have to make many changes, but I think I’m doing it. Thank you!
I think everyone has their own damage system, there isn’t a fixed answer.
Having said that, if you’re doing a trace to the enemy to fire the projectile, why not damage the enemy then? ( with the line trace ).
You need to use custom collision channels. You can make as many as you like. So you can have no collision in the normal sense during the game, but have a special channel just for line tracing enemies.
Find out more at:
Now I found to main issues with the line trace damage system. First, one of my enemy character meshes don’t block the line trace even it’s set to Block All. And second. when I set the enemy’s mesh to Block All, I’m flying away when the enemy hit me with melee attack. I’m flying 10-20 meters away and this isn’t realistic and isn’t cool. Does anyone know how can I fix this?
Now I found to main issues with the line trace damage system. First, one of my enemy character meshes don’t block the line trace even it’s set to Block All. And second. when I set the enemy’s mesh to Block All, I’m flying away when the enemy hit me with melee attack. I’m flying 10-20 meters away and this isn’t realistic and isn’t cool. Any ideas how can I fix this?
Ah yes, I forgot for these options. Thanks, that could solve the second issue, and for the first, can you suggest why a mesh can’t block line trace when it’s set to Block All?
You have to set the mesh collision in the BP and in the mesh editor.
Does it have a ‘green box’ collision in the mesh editor?
I mean the far right icon in the mesh editor:
When you click that ‘collision’ icon you should see the collision box drawn around the object in green. If you don’t, then you need to use one of the generate options in the collision menu.
Physics wont have anything to do with it.
No, when I check show collision it highlights the terrain with green line. Also it looks like there is no physics asset on this mesh, could this be the reason it doesn’t respond to the line trace?
This editor you showed is for static mesh, how can I use it for skeletal?
Ok, sorry, not sure about that…
Sounds to me like you need to do a lot of homework on collision detection in Unreal. There are a ton of tutorials and videos out there and I do believe Unreal has a Live Training video on it. Another factor may be that you need to select the option to “sweep” when detecting your collison, what happens is if your projectile is moving fast enough, one tick it is not colliding, and the next tick it has gone past the hit zone so does not collide. Using sweep should take care of this I believe.
Also, check if you are using simple, complex, or complex as simple for your collision settings. Both objects need to be using same channel with same settings. Collision detection can get complicated, and as there are many things that can be going on, without seeing your actual project its hard to give you an answer. You just simply have to learn everything you can about collision. It is what I had to do to get my collisions working as I found it very difficult getting help because there are so many tings involved. Also look into custom channels. And check your collision settings both on Blueprint and the Static Mesh. If static mesh does not have a simple collision, you can add a collision component to the BP, or use complex as simple, which uses the wireframe of the mesh for collision and is not recommended for performanc reasons.
Actually, creating a physics asset did the job done. But now I saw other problem. Sometimes when I shoot, the line trace is getting blocked right in front of me. It looks like it is only with the shorter weapons. I taught the capsule component of the player character may block the line trace, but I made custom collision preset and that didn’t solve the problem.
When you do the trace you can set ‘actors to ignore’, how about that? ( also ‘ignore self’ ).
Yes, that worked, thank you very much!