Sunday, July 10, 2016

Well, that's funny

No new build today - sorry guys!

So last week I said I wanted to work on providing the player better feedback on when they hit a wall and continue charging into it. I wanted to turn it into a "powered-down" status effect that lasted for a period of time proportional to the strength of the charge. But I found out something funny: My code for hitting a wall seems to only be occurring a small percentage of the time.

This actually makes some sense. The way I handle collisions currently, all I do is cast rays from where the player *used* to be last frame to where they are *this* frame. This lets me sense whether the player has passed through an object that they shouldn't have. It also gives me the information I need to cast rays from where the player is *this* frame to where they should be *next* frame. This tells me when the player is about to enter a warp wall, or a wrap wall, or hit a bounce wall, or whatever.

I... I don't ever actually call OnCollisionEnter or OnTriggerEnter. This is a weird thing to do, but the player is always moving so fast that these methods would likely fail to fire a significant portion of the time. If I comment out my raycast code, the player regularly passes through walls on a charge, for example.

That raycast code is also in charge of what happens when the player hits a wall, which is where I would *like* to trigger this powered-down status effect. I found out, however, that there are times when the player hits a wall and this code just... never fires. I have no idea how this is possible, since other parts of the same block of code *appear* to be firing.

This of course can't be the case, so next week will be spent debugging this, and possibly rethinking how I handle collisions globally... One thing that was suggested to me at the Indie City Games meetup was throwing out the way I currently move the player (which uses Unity's 3D physics) and just use Unity's 2D physics. I'm understandably reluctant to switch over to a new system, but it's worth looking into.

One thing I did do this week was fix up a minor error where enemy projectiles would interrupt the guide line that extends out when you build up a charge. Not worth making a new build for, really. You'll see that change next week though.


No comments:

Post a Comment