Friday, August 26, 2016

TOE week 12: Unrefined Ducking



                I didn’t want to work on the game this week, for two different reasons. First reason being I was sick. Wife went back to work found new germs and the house got sick. So I spend Monday curled up on the couch binge watching Stranger Things and eating hot soup. Second reason being I thought that implementing ducking would be hard. Was I right? Kind of but not really.

                I have this fancy Ray Cast system set up for the player. Basically my player sends out a Ray and the distance of the ray determines the player’s speed.  So if the player is colliding with a box the distance of the ray is zero and so the player’s speed is zero. But the hit box I have representing the player is basically the player’s feet. So I needed to double the player’s height and add the player’s head, ‘so to speak’. This seemed really complicated to do. I knew how I thought this should work but making it and thinking about it ARE two different things.

                Well turns out that I just needed to add the player’s height to the Y calculations up for Ray Casts in the position Y direction. Negative remains the same. And then increase the height of the X direction and suddenly we are Ray Casting with everything covered! I do need to better look at this because it was some hack code to accomplish this but it does work.

                Then it was just a matter of moving the player’s head to the position of the player’s feet in the Y direction when user input is negative for Y. Setting this up caused I bug that I haven’t quite figured out yet. Basically the bug goes something like this: nine times out of ten ducking works as expected. Player presses down and head.Y is equal to feet.Y. Then there is the one time when the head.Y is -1 lower than feet.Y. So it creates a situation where you have crouched SO low that your head has fallen through the ground.  As a tester inconsistent bugs were slightly annoying but as a dev they are the WORST. A game is made out of so many variables and tracking down the one thing that one thing that broke everything is a pain in the ass. 

                There are other things not quite right with ducking at the moment, like you can move left and right while ducking. So I have imperfect ducking at the end of the week. I mean it was less of a head ache to set up than I thought and I have a rudimentary version actually working, so overall I will call it a B-! 

                The thing I set up earlier in the week before ducking was wind tunnels and treadmills. Basically a vector that pushes the player in a direction when they collide with this type of collision. This was something else that I thought would be difficult and turned out to be REALLY easy. I slapped on some classical music and in about an hour I had it working rather well. Then two more hours and it was refined push collision. Maybe by the time next week rolls around I will have refined ducking? Who knows. 

                I think I am about ready to start arting this here game thing. Maybe slap some pretty pictures on this and finally show off what it is supposed to look like! Oh I guess I have to make those pictures. Going to close with a video of ducking and push collision. 

 




No comments:

Post a Comment