So for my #1GAM challenge I decided to use Physics Ray Cast to detect collisions.
Originally I imagined using a "corner point" system thinking to myself this would detect anything right as I hit it.
Indeed this worked very well as long as the player was not jumping!
The player sprite is 128x128 pixels and the world blocks are 64x64 pixels.
So in scenario 1 you see if the player walked into an object of any kind there would be two collisions (noted by the red lines for the physics ray cast).
However I started noticing odd behavior when I jumped. Sometimes I would jump and the middle of my player would hit against something ; and nothing would happen.
So we see in scenario 2 as soon as the jumping is in play this set of ray cast points was in fact insufficient. As the visual portrays what happens sometimes during a jump the sideways stack of blocks can hit between ray cast points.
So finally I came up with the system in scenario 3.
There is no gap on the player large enough to slip through and this has the benefit of detecting if you hit something from any angle on left edge, right edge, or center (for any side).
And per the spacing I made (perhaps not 100% accurate on the mock up here) there is no room for 64x block to slip through undetected.
I'm glad I spent some time testing this in game otherwise this might have slipped through and presented some possible exploits, and game bugs for Space Chickens vs Angry Zombies.
- punch out
No comments:
Post a Comment