Collisions can be Tricky - Mason Miller


Preface
Collisions can be tricky, it can be even more tricky when your player is a ghost that is set not to interact with anything. For the premise of our game to work we need to have very limited collision within the level and with objects so that the players movement isn't abstracted.

Problem

 In order to show how an object would kill the player, I needed to quickly set up a basic interactable object that would fall and delete the enemy. Setting up the Chandelier was pretty quick and easy, it's execution however was not. After I set up the mesh and collision in c++, I tried to set the handle overlap function to handle both falling onto the floor and hitting an enemy by checking for the specific actor type of our enemy, and if it was it would delete it. To make the chandelier fall I was also checking for the player, but at the time we didn't have a code version of the player to reference so I just checked for when any character would make contact with the object it would trigger the fall. Nothing happened however, the enemy and player would not interact with the collision box in any way.


Solution

It turns out, that two things were wrong. One, our player was set to not interact with pretty much anything, the only type that would register actor collisions was the vehicle type, and two, I was using the wrong method to get the collision between two classes. Starting with the box collider, ECollision was a part I was missing for the collider and didn't initially consider, so I set it to check for QueryOnly, and SetCollisionResponseToAllChannels was also needed so that it knew what to respond with, finally, it needed to be bound to the handle overlap function so that whatever is in that function gets called when it gets interacted with. With the box collider set up it would register when something hit it, but the player and enemy still were not being registered at all. The final fix ended up being with the handle overlap functions I wasn't checking for the right classes so it wasn't doing anything to the ones that were touching it. The enemy was easy since we already have a code based actor for it, and I just checked it for that during the collision and it worked perfectly, the was more tricky since at this point in the project we do not have a code based player, so after a little experimentation I figured out I just had to check for a character, since the destroy function is already set for the enemy, if any other character connects with the chandelier's collider it won't be deleted but still enable it to fall.

Get No Rest For the Wicked

Leave a comment

Log in with itch.io to leave a comment.