Skip to content

How do you separate collisions so certain ones don’t interfere with other ones?

I’m making a vampire survivors / megabonk style game, but adding my own twist.

I currently have the damage system from enemy to player and player to enemy damage set up. Every time I try to implement the player to enemy damage being an auto attack seeking the closest enemy within a collision sphere it breaks enemy to player damage. It’s very one or the other works and I can’t figure it out.

I’ve been watching every video I can and looking for tuts to no luck. I’ve experimented with collision channels a lot and it seems easy but to no avail.

Any help is VERY appreciated.

Edited 24 Oct 2025. We only hold this version.

4 points12 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
4 · 83% up
Kind
Text
ID
1ofbnul

Author

27
posts
48
comments
17
media
View profile

18 comments

Two questions:

  1. What engine are you using?

  2. When you say, "it breaks enemy to player damage", *how* does it break? Is damage not making it to the player due to unwanted collisions or something?

Since you don't specify, I'm going to assume you're using Unreal. If you're not, then this will be slightly less useful, but it's probably similar in other engines. Unreal's collision system is pretty flexible, but also pretty confusing without banging your head against the wall a bit. One of my favorite pages related to Unreal collision can be found here:

https://www.unrealengine.com/en-US/blog/collision-filtering

The gist is that when setting up collision in Unreal, you're building a contract between different object types for how they respond to one another. Ignore, Overlap, and Block are the options, and when two objects, A and B, enter the same space the engine will select the least blocking interaction based on the combination of the rules you've set up for A vs. B and also B vs. A. For your project, you will almost certainly need to create custom object types so you can create accurate rules about how those object types collide, or don't collide, together. For the example you give, it sounds like the collision sphere you're testing with may be set up so that enemy damage collides against it, when that's not what you want. The collision sphere needs to ignore enemy projectiles/hits, while overlapping enemies to be able to test against which is closest.

I suggest spending some dedicated time reading the Unreal docs and testing out collision scenarios outside of the mechanics of the game itself. If you can get test objects behaving the way you want in isolation from the rest of your project, it can help simplify the complexity while learning how it all works.

https://dev.epicgames.com/documentation/en-us/unreal-engine/collision-response-reference-in-unreal-engine

2 points

I apologize not including the game engine I meant to do that but you were right about it being unreal engine five.

You’re definitely right I should’ve specified better, what I mean by breaking it is the player starts receiving damage from the collision sphere that’s supposed to be giving only the enemy damage. So it’s working just mixing up collisions.

I’ve spent the most of the past couple days trying to figure out object channels and it might just be that it hasn’t clicked yet or I’m doing something obviously wrong. I can’t do it right now, but later tonight, I could snack some screenshots from the project. I’ll also read up!

3 points

Within that area, you can detect things. You have logic in place to detect that, for example, this is an enemy or this is an enemy of type X based on its ID. It sounds silly, but it's a valid argument.

1 points

Do you have any tutorials or recommendations on how to set up that logic. I’ve had very little luck with what I found.

1 points

I don't know UE5, but this sounds like what I know as a collision mask issue. I believe UE5 calls it collision channels.

1 points

Disclaimer: I don't know much about unreal engine 5 but i do know game development. I can try give you suggestion on debugging it.

It could be that you have other colliders on the character that could be detecting the collisions for everything. Try removing everything to a bare minimun. Player, enemy, one collider and shooting. No movement or other stuff. Just shooting and see if it collides. Then put an enemy in between the player and enemy and see what collides with what. Have log outputs and see.

You can make the bullet into a trigger collider And add a target tag when bullet spawns. when collided, you can check if collided has that tag.

Instead of using a collision sphere to detect how many enemies are near to player. Why not keep a list of enemies and update it as enemies die and spawn. Then when you want to shoot, go through every enemy and find the closest, see if it's within a range and then fire it. That way you can cut down that physics calculated spheres.

1 points

I’m going to try all of this! Do you any documentation or tutorial videos on the list of enemies approach?

1 points

Not exactly. It's just something close to object pooling. I'll tell you the process.

  • Create a list or array of enemies.
  • When you spawn enemies -> add to the list
  • When you destroy enemies -> remove that enemy from the list.

Or if you are using complete object pooling or would like to implement it.

  • Create all the enemies (30-40 or depending on how much enemies you want on the screen at a time). Keep them deactiavte/hidden/ away from the game area (like 1000units away or something). Have a tag that shows if the enemy is active or not.
  • Then when you want an enemy, use the list, get the enemy with the tag that is not active and then activate it, set the values and then move it into the screen.
  • when the enemy dies, deactivate/hide it. Set the tag to not active. You'll be able to create the list, and also remove the constant spawning/despawning of enemies. Small optimization.
1 points

There's no way of knowing unless we know what game engine you are using, if you are on godot I could maybe try and help but it would be best for you to edit your post and include the game engine

1 points

I’m an idiot. I meant to include that it’s an unreal engine 5!

2 points

cast to a separate character on overlap. if you need to have multiple different overlaps on one single collision, make a sequence as the first node to do multiple casts.

1 points

Here's the basic principle I would take, you're going to update all the AI enemy to move etc.., so within that loop just do a quick distance (bit o trig with radial collision) check from each AI to the player, store the closest (maybe more than 1), then distribute that auto attack to that list. (you can also optimise this, but ill let you figure that bit out).

1 points

I would in general suggest not to use a collsion sphere to seek the closest enemy. You have your and your enemies positions - just loop through your enemies and get the ID with smallest distance to you. There are simple ways to make sure to check only close enemies.  But with many more weapons you would need so many different collisons and masks, which will make your whole game run pretty bad I fear.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.