Sunday, December 31, 2017

NYE Is the Deadline!

(This week's (and I guess this year's) build is up right HERE!)

This week I did some tinkering. I realized that the reason why moving objects are passing right through the player if the player is not moving is because, duh, the moving object itself doesn't have a rigidbody attached to it. It's really only conspicuous in one level, so I only added a rigidbody there. It's possible that that decision comes back to bite me, but it's also the only place in the game where you are advantaged by letting a moving object try to move through you.


But that got me wondering about colliders, which got me wondering about the problem I've been trying to solve for a long, long time - the issue of the player mysteriously losing a ton of momentum after interacting with walls mid-charge. I'd played around with different colliders and things in the past, but I couldn't remember if I'd tried just making the player's collider into a trigger. There would obviously be certain things that would break, but would it solve the issue of momentum loss?

As it turns out, the game runs pretty well even when the player's collider is just a trigger. Most of the logic keeping the player from going through stuff is done with raycasts. And lo and behold, I experienced no loss of momentum on several playthroughs of the game. I won't say that the issue is fixed, because I've been wrong about this before, but it's promising. Of course, I can't just keep the player a trigger all the time, so I just have the player's collider turn into a trigger during charges. It actually works out great that way, since the speed at which the player moves during charges is the whole reason I needed to write the raycasting logic in the first place. As to what was the cause of the issue in the first place, I guess that under certain conditions, when interacting with a bounce wall, the player would turn in such a way that a corner of the player's collider would intersect with the wall's collider, Unity's physics system would then try to stop the player from moving... I think.

We'll see if this solution causes any other issues, but for now all I need to do is to solve some cosmetic bugs caused by this. On an unrelated note, I also need to make boost plates play a sound effect when you go over them. I can't believe I didn't do that yet.

As always, the charging-up noise is by Javier Zumer. I'm using it under this license.

No comments:

Post a Comment