Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Animated Meshes And Collision Overlap

The Problem:

This week I ran into a bug where when I would animate our doors on a timeline they would sometimes get stuck inside the player when the meshes collision fails to trigger as the door swings.  While the bug was intermittent, it was frequent enough to be replicatable.  


The Solution:

In testing I tried to implement a collision check on the door mesh but the check would not return true for the player no matter what I tried.   After researching how this issue is usually handled I was presented with three solutions: Solution 1: Apply a collider over the door that keeps the player from ever entering the collision space and moves the player out of the space when the door moves.   This solution Does not feel good or operate well unless you integrate character animations that lock player position and control to a certain spot while opening. Solution 2: When a door collides with the player it pauses it's animation until no longer colliding. There are many issues using double doors int his method as the timeline can not be paused and resumed from any method I was able to deduce in UE4 that wouldn't put the game in the state of a hard lock. Solution 3: Place a box collider on the door hinge that knocks the player back every frame it is in this collision space.  While this solution works the best, I am of the opinion that it is only the best of 3 bad options.  The issue with this solution is that our door asset doors are built in such a way that the door's origin is at the hinge(which allows the door to swing with easy math.)  So when the box collider is created, it is created at this origin and extends into empty space on one side of the door as far as it extends into the space the door swings through on the other.  This creates false positives and the player is tossed back from the door frame regardless of the side.  The transform for each door would have to be adjusted per frame with expensive math just to place the collider correctly and because it is axis aligned bounding box it is still overly aggressive. 


  Post Solution: Going with solution 3 I have managed to get the character stuck twice in around a thousand executions attempting to get stuck which for now is an acceptable margin of error.  Revisiting the idea,  when it is time to optimize I will try a few new functions built into unreal to test overlap on actors and at the end of the door animation if the player is stuck I will slowly push it out until no longer stuck if I can get the detection to fire off next time around.

Support this post

Did you like this post? Tell us

Leave a comment

Log in with your itch.io account to leave a comment.