Fixing Terrain Collision by: OsirisCastro
The Problem
This week while testing, I encountered a game-breaking bug that was having a profound impact both on the player's experience with the world and game performance: the player's projectiles were completely ignoring the terrain going right through them, being able to kill enemies and damage them behind walls, which is something we obviously don't want there.
For an end-user, this is a disaster. It completely breaks the game's immersion and fairness. Also to make things worse, the enemies could shoot you through solid objects, with no means of defense available to you. This kind of bug made the game feel unfair, and unplayable. Making sure that the rules of the game are consistent and dependable is most important for a good user experience, so this was my first priority to fix.
Solution
The root of the problem was in the Unreal Engine's Collision system. The projectile's collision presets were either not set up correctly at the beginning or I myself overlooked multiple errors that caused this to happen later on into production of the game (which was now),all of this caused it to not generate overlap or block events with the WorldStatic channel (which is what our terrain and static meshes use).
My solution involved a deep dive into the Collision Presets for the projectile's Sphere Collision component. Here’s a breakdown of the steps I took for any fellow devs who might run into a similar issue:
- Re-established the Core Setting: I first ensured the Collision Presets were set to "Custom" this is the key to having fine-grained control.
- Defined the Collision Type: I changed the Collision Type from WorldDynamic to WorldStatic. This was crucial because our terrain is a static object, and this change ensures the engine's physics system treats the interaction correctly for our use case.
Adjusted Collision Responses: This was the heart of the fix. In the "Collision Responses" section, I set:
- WorldStatic: Overlap
- WorldDynamic: Ignore
For overlapping channels like Pawn, PhysicsBody, Vehicle, and Destructible, I also set them to Overlap.
The goal was to make the projectile a Query-only object (meaning it detects overlaps but doesn't simulate physical physics collisions like bouncing). We don't want the projectile to be physically blocked and drop to the ground; we want it to overlap with an object, trigger a hit event (e.g., deal damage, spawn a particle effect), and then be destroyed. Also remember to enable into all of your map objectives Generate Overlap Events as it will sync up with the Projectile and destroy the projectile that comes in contact with that terrain.
This fix ensures that the projectile now correctly detects when it hits the terrain or an enemy. The end result is a combat system that feels solid and fair. Players can now use the environment to their advantage,all of this provides that satisfying, professional polish our team is aiming for.
Get Quantum Gladiator
Quantum Gladiator
Status | Prototype |
Author | Dev Dynasty |
Genre | Shooter, Action |
Tags | 3D, Arena Shooter, Top-Down |
Leave a comment
Log in with itch.io to leave a comment.