How to determine hit collision

Hi,

Just wondered if there was anyone who might know how to help me with 2 issues that I feel are in the same section.

So here is the issue, I am trying to make a Hit Scan shooter, you may as well say similar to COD though I have no intention of making a COD clone, but I like hit scan shooting for the purpose of my game which is going to be an arcade MP shooter. I don’t want real world bullet physics ETC, it is going to be fast and very arcadey. So I have set up my hit scan and it works, it produces an emitter at the location it hits and it destroys a destructible cube (though with no impact) and it deletes a static mesh from existence, both of those outcomes I wanted.

The issue is if my player walks in to either the destructible mesh or the deletable static mesh it kicks off the hit chain. This is undesired, I tried turning off the collision for pawn, but I just walk through objects, also undesired. So I want both Static Actors to block the player from walking and allow climbing, but when they shoot them (they receive the hit scan) they register that hit in order to spawn the emitter and then either get destroyed or disappear.

The second issue, which may be solvable from learning the first answer is, if I place a destructible mesh on top of a deletable mesh and shoot the destructible mesh, the falling parts of the mesh “wake” the deletable actor and delete it. This is an undesired affect, I only want the hit scan from the player’s gun to “wake” the deletable actor.

Any help would be greatly appreciated, I am hoping I have just missed something really simple in either the collision settings, the “wake” settings or have missed a node in Blueprints that would allow me to determine which hits wake and object.

Many Thanks

Hi MAIKERU Jackson! Could you post screenshot of your blueprint code handling the destruction/deletion of your meshes?

Hi Elou44, The destructible mesh didn’t require any blueprint code, it just “wakes” when it receives a “hit” event, upon waking it is destroyed. So I don’t have any code to show you RE that. As for the mesh that is deleted there are only 2 nodes in it, Event hit → Destroy Actor.

I could send a screenshot of that but didn’t think it was overly worth it?

Thanks

Hey, Your setup is indeed quite simple but adding screenshots always helps people understand and it gives context imho. Could you show your hit scan code please.

This tutorial may help you understand how collision properties work which will hopefully help you understand what I am about to recommend next.

What you should probably do is create a custom collision channel (by going to project settings tab then collisions…I think) and creating a custom channel for your destructible meshes. Set them to ignore themselves, block the pawn and block or overlap (I forget exactly I think both may work for your setup) “visibility” channel. This will allow line traces to register the mesh and you can fire off events from there.

True.

Thanks Nebula Games Inc, appreciate the response and the video, I watched it through but unfortunately could not extrapolate any information from it that helps me with my issue in as much as I can control the blocking, but it still triggers the hit event, which is what I need to control it needs to block but not trigger a hit from the player, but it does need to be able to receive hit triggers from other sources.

I should say more accurately it should only receive a hit trigger from one source as opposed to any other, while blocking all else in the world.

What is your collision setup for the meshes? Have you considered adding a box collision around your objects, those are usually easier to control/respond better than the mesh itself. Also, just so I am clear, you have 2 meshes a static one that sits in the world and a destructible one that I assume you spawn in when the static mesh is hit by the weapon yes? So you fire the weapon it hits the static mesh, you delete that mesh and spawn in the destructible type which breaks apart instantly? That works fine, BUT those events are also triggered by the player walking into the static mesh as well? If this is the case, show us the character collision settings and the mesh collision settings. Something is off with how those are set up.

Hey, so the deleted mesh and the destructible mesh are separate concepts. I made a destructible mesh that I just drag in to the world, add physics to it, set it to “not awake” I set up a hit register, now anything that hits it wakes it. (which is not the idea, I want them to act as structures that block a player, that can be stood on and so on) I only want the hit scan from the gun to apply any damage or hit registry to the destructible mesh. So at the moment when I shoot it, it gets destroyed as is desired but if I walk in to it, it also wakes it. I have tried to use the object hit function and cast to the character and set up a bool in the hope that if it registers the player character as the object colliding or overlapping the object it will do nothing…but it didn’t work as intended.

I then have a mesh I want to delete when shot, it is for a different weapon type (eventually) that will just disintegrate the actor. It is not a destructible mesh it is just a static mesh. The hit scan I have set up registers and deletes the block as desired but if a player walks in to the block it also deletes, if I put a destructible mesh on top of the deletable mesh and shoot the destructible mesh it then “hits” the deletable mesh and deletes it.

So I really just need some way of determining what hit type registers with the object, the collision is almost null and void. (other than registering the hit scan from the gun)

Hi, I have a pretty simple solution in mind but to know if it’s viable, I need to be sure that the gun is the only mean to destroy the meshes.

There in lay the issue, that is the exact outcome that is desired.

The 2 Meshes are not linked. One is a destruction mesh, one is a delete mesh. The destruction meshes are there for environmental damage from gunshots, grenades etc. The other one just deletes from existence this will be due to energy weapons that vaporise blocks, players, ETC.

So collision is less of an issue for me than hit detection and control, the cubes sit in the world fine and they block each other fine while they are asleep. However when they register a hit they wake, when they wake they then wake anything they are near. So if I place a destructible block on top of a deletable block (not in the same space but physically on top stacked) shooting the destructible block with delete the actor below, as soon as it wakes it registers a hit event on the block below.

So really I just need to know how to control what can wake objects and what can’t. I was hoping someone would say it would be something simple like cast to player character branch if NOT player character wake, if player character do nothing. Something like that, but haven’t been able to work out how to control the hit registry to that level.

As documented on the LineTrace node, a line trace whose Trace Start vector is within the collided object will have conditions such as a trace length and time of 0. You can test against these conditions to change the logic of your shooting based on the fact you are inside a destructible actor or not.

Hi MAIKERU Jackson,

If I understood your needs correctly, here are a few easy steps to get what you want :

  1. Create a new blueprint class inheriting from ‘StaticMeshActor’.
  2. Implement the ‘AnyDamage’ event as follows (same logic applies if you want to destroy a mesh into pieces) :

3 . Change your firing code to apply damage to the hit actor (‘Base Damage’ parameter must be greater than 0).

Hope it helps!

Cheers.