Header
i don't fall asleep when I gameeezzzzzzzzzzzzzz

Dev Diary - Fixing a long standing bug....

Over the weekend I was working on the VR locomotion system. I may make a video this weekend actually, it's coming together pretty well. I've migrated fully over to VRTK, which I'd used in bits before, and making modications as I need them.

Sometimes I like to work on a few things at the same time, it helps keep me interested and focused. So with the locomotion system about 80% (working, just a few niceties to iron out), I started working on alternating coloured platforms. Before I got far in that (I'd literally put a few platforms into a new level) I re-discovered a bug I've long had - when jumping up, if you clip the edge of a platform, you shoot up in the air. It's actually kind of fun, and I can repeat it, and if the gameplay didn't need to take into account the limited VR Room Space I'd probably expand and keep it. Trouble is, with it you can cover so much ground, you very quickly run out of Room Space real estate.

I'd not had much luck hunting the issue down, and I kind of left for a while figuring I'd get round to spending some serious time on it "later". Well, Monday night, having done no coding that evening, I was just off to bed when the cause hit me - I have a "Just Started Falling" state, which only lasts 0.1 or 0.2seconds, which allows the player to jump AFTER they have ran off a platform. It's to make the game more playable. For this brief period of time, gravity is reduced to one quarter, so any upward jump would feel decent enough. To detect this, I have a ray cast from the center of the player straight down, which if it detects anything in a Terrain list, knows the character is Grounded; if not, I turn the bool to False.

Well, what is happening is when jumping up, this ray detects the edge of the platform, and thinks you have landed, even though you really haven't. It then sees the ground has gone as you get a bit higher, thinks you must have landed and fallen off the edge, applies the state "Just Started Falling" (actually SGstate_FallingStarted.cs) and drops gravity, It then detects that jump is held, and applies a new jump, which is an upwards force. So yeah, the character goes flying.

I'm glad I found it, but the solution is proving tricky. Mainly because looking at this single raycast, it's become apparent it is responsible for more errors and strange bugs I sometimes encounter. The solution is quite involving but will entail me casting a whole bunch of rays from the player and detecting the floor around the player - I'm thinkin of 5 in total, including the original center one, with an additional one front, back, left and right; I may add four more in the corners. From this information I can get a much more accurate picture of the character and where they are standing. This means I can eventually apply context animations, like running alongside a drop, keeping the feet together, something like that. Flailing arms on the edge of a ridge, it the drop is a long way down.

Basically I've opened a can of worms and it's a lot of work to add all the new States in, taking into account every eventuality. On the plus side, it will add some nice little touches and I do want to push the "character feels part of the surroundings" gaming philosophy, so in the end it will look pretty cool.

A lot of work in the meantime though. And I'm short of a lot of animations Sad