Hi all,
I'll get right to the point:
My game, a 2D platformer of sorts, uses Unity's tilemap system for terrain, but characters (and as much else as I can manage) will be controlled with my own movement system using raycasts and direct transform adjustments, as I did in my first project (years ago, at this point).
The bug I'm fighting with seems to be less specific to the scenario in which I was seeing it than I initially thought, and is likely to be indicative of a broader flaw in my design. In this case, though, I'm trying to make my character do a little hop (like knockback) straight up into the air when they touch something hot. This can be regular game objects (projectiles, enemies, burning decorations) or tiles that have a burning flag set.
My movement code checks to see if a touched tile has any effects that it should apply to it (the moving object, such as the player), and sends that message before returning true (if ground/ceiling/wall is hit) and false if not. The return value is used in the PlayerController to set states such as grounded, stop accumulation of upwards velocity (if jumping and hitting a ceiling), and (eventually) pushing against a wall/obstacle.
You might already see the potential issue here: The movement code detects a (in this case) burning tile, which calls OnTouchedBurningTile() on the player, starting the hop, but the last part of that code tells the PlayerController that a floor has been detected, so the player should be grounded and the vertical velocity should be zero'd out. This results in a very tiny hop that's only perceptible if I set the value super high to compensate, which is what I've been doing just to ensure that something is happening.
I could set up a bunch of flags to allow for this exception, but I think a cleaner solution is needed. Any help at all would be greatly appreciated.
Here is the relevant code: https://paste.mod.gg/fsqhunxlyzyj/0
Thanks to anybody that gives this their time.
A tool for sharing your source code with the world!