I’m making a 2.5D platformer, and I have a strange ‘bug’ in my code.
My Player (driven by a CharacterController) has two Update states: UpdateControl, for regular movement, and UpdateKnockback which throws the player into the air a short distance and disables controls until they land. UpdateKnockback is used when the Player is hurt.
I’ve had this effect working great for a couple of weeks. But I just found a scenario in which it acts very oddly.
If the ‘ground’ is a single BoxCollider, there’s no problem. But if the ground is made up of multiple BoxColliders, and the Player Knockback effect causes the Player object to land on a collider other than the one it was on when the Knockback effect was initiated, the Player will instantly jump the same distance as the width of the collider it landed on… if that makes sense.
I’ll try to illustrate:
AAAAABBBBBCCCCC
Imagine AAAA is one BoxCollider, BBBB is another, and CCCC is a third. All three make up the ground.
If the player was standing on AAAA when they were knocked back to the right, and landed on BBBB, they’d instantly jump to the width of BBBB from their current position, ending up on CCCC. So if they landed on the 2nd B, they’d jump to the second C. I hope that makes sense.
I can paste code if it helps, and I expect it will, but there’s a lot of code that might be causing the problem and I’m not sure where to start.
I only post this first request without code incase this is some kind of recognisable collider-update issue or something that someone has come across before.
I know there are some minor issues with collision volumes being updated after the Update method because I have another problem where the player dies in lava, is respawned, and instantly takes damage again. But that’s probably one to solve later.