Hello people!
Can someone please explain to me how collisions work on instanced meshes?
I’ll try to explain my problem in detail.
I am making a snake game in the first-person perspective. The tail of my snake is a cube static mesh (just prototyping for now) which is generated procedurally from my player character, every time that my snake eats an apple.
The issue is that every time my tail overlaps the apple, the score increments, which of course is something that I don’t want since that suppose to happen ONLY when the head of the snake overlaps the apple.
Now, I tried to set collisions with dedicated channels to avoid this, but they do not work at all. Seems like I can only ignore all or block all.
I have no idea how to fix this, any tip is appreciated.
Thanks in advance.
1 Like
It might be easier to fix the eating 
Why not have a collision box only on the head?
Apart from that, collision on ISMs is very similar to normal meshes.
The key concept that you are perhaps missing is that both sides of the collision must be set up. i.e. if an object of type tail is set to block objects of type apple then that block will only work if apple is also set to block objects of type tail.
And the hierarchy is that if tail is set to block apple but apple is set to overlap tail then overlap events is what you will get.
So,
Set your tail type to ignore apple or, apple to ignore tail.
And it that is not subtle enough for you then you can use the information provided by the overlap event - such as other actor or other component - to filter exactly.
It does work. I suggest you do some general experiments on how this all works to get it clear in your mind.
cheers
Podge.
Thanks a lot!
I already tried to set up collisions on both sides but unfortunately, it didn’t fix 
So far, this is the only way that I found to fix it:

I would like to try the method that @ClockworkOcean suggested. If it works, I can avoid hard referencing the player.
Let’s see. Thank you, guys!
Ok nope, I just realized that if I remove collisions from the mesh, it will be impossible to interrupt the game when the snake’s head is going to overlap it. 
Surely you want a collision box on the head of the snake to know when it eats something?
So the head is special, and the tail does nothing ( collision wise ).
What’s your setup? Is the snake one blueprint? What happens? Why bother with ISMs, unless the snake is about 5km long? 
So yes, the snake is a whole blueprint right now.
I have the character mesh (which is the head) and the instanced static mesh component which is the tail and is generated procedurally everytime the snake eats an apple.
There is also a collision box on the snake’s head, and I use that to check the overlaps. There are basically 3 things that can be overlapped:
- The wall → GAME OVER.
- The apple → Apple collected + increment scores.
- The tail → GAME OVER.
OnComponentBeginOverlap the collision box will search if the overlapped component implements an interface. Only the apple has that interface. If it doesn’t the GAME OVER logic will be fired.
I also have a BP_Apple who has collision. In this case the logic to destroy the actor and increment the scores will be fired only if it overlaps something different from the player’s collision box or the tail (you can check the screenshot that I posted above).
I am really sorry for the confusion, I hope this clarify things a little bit 
1 Like
OK, all sound eminently logical 
So now I’m wondering why you’re having any problems. If there’s a check to see if the overlapped object implements an interface, we’re home and dry, no?
Not really, because the interface is on the apple. If the player overlaps the apple it will be destroyed since it overlaps the interface. If not (like in case the overlap is on the tail), game over logic will be fired.
Now the problem is when the tail overlaps the apple, because in that case, it will be still collected.
I can’t quite imagine your setup. I’m thinking you have segments in the tail, are you adding box collisions with the tail parts?
Anyway, everything can be done in the snake. On overlap, basically everything is GAME OVER, unless it’s the head with the apple. In which case, destroy the apple, and add a segment.
So all the tail parts call one overlap event, but the head calls another, which checks for the apple.
Setting everything from the Player actually fixed the issue, thanks a lot @ClockworkOcean ! 
1 Like