I found out why that was happening

Published September 24, 2020
Advertisement

It's been a long week.

The SSD arrived. I cloned both OS' to it, set up a dedicated swap partition and now boot into Windows or Linux in a matter of < 10 seconds. This feels like an entirely different machine, better than when I bought it in late 2015. The old hard drive is now a shared data drive between both OS'. It's fast, it's stable, it's possible to get work done on it again. And not a moment too soon.

The million dollar question: Why can Bob walk through walls and fall through the floor when he should be colliding with them and stopping?

The weird part about this one is that at one point he was stopping at X axis obstacles. Then I did some tuning and he didn't. The tuning was necessary, I've found a tremendous amount of technical debt in the Valkyrie.GameLogic library. Those classes needed refactoring and they are much better off with it. Changes made this week:

the GamePageViewModel - which was growing and becoming a God class needed to separate out the collision-checking logic into a dedicated class, CollisionResolver. This resolver object (named collider and owned by the GPVM) has a List of <ICollidable>, an common interface developed so that actors and obstacles can call their .Intersects(other), .Contains(other) and other useful API directly onto each other regardless of what class they are. I still had duplicate collision-detection code in Actor and Obstacle, so now they both derive from an Entity class which implements ICollidable. Once Actor and Obstacle were both calling the exact same .Entity functions, and I was satisfied in unit testing that they worked, I knew my problem had to be somewhere else.

On a hunch I put a breakpoint in collider.EvaluateMotion() and did a debug run. I modified the map so that Bob was inside an obstacle at spawn time. Once I hit a button, commanding Bob to turn, he should immediately have collided. What I found was fascinating.

GamePageViewModel iterated through the list of Actors, passing each one to collider.EvaluateMotion(). When it was Bob's turn to be evaluated, .EvaluateMotion() first called .EvaluateHorizontalMotion(). From there, it saw that Bob had neither left or right commanded in his control status. So naturally, .EvaluateHorizontalMotion() skipped the calls to both .movingLeft() and .movingRight() and Bob didn't collide with anything.

So after all that, it turns out the problem is in Bob's ControlStatus. At some point I'd hard-wired the virtual gamepad buttons to manually cycle Bob's functions and then forgotten about it. So tomorrow I'm going to run down the problem in the Valkyrie.Controls library and hopefully put an end to this silliness.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement