Today was the chance to make a neat twist on the simple infinite runner; yesterday I had shown a scrolling environment, with two sides for flipping. For the flipping player, I put in a copy of the same orange circle as a player with a 2D Rigidbody. Luckily enough, the rigidbody in two-dimensional gameplay has a specific value for gravity scaling (-1, -2, 4, etc) instead of a boolean check for using gravity.
However, it was tricky balancing the jump mechanic (adding a force in the upward gravitational scale direction) and the flip mechanic. For the flip, there is currently a 100 percent chance that the starting of a touch that instantiates the jump always happens with the flip, meaning that the flip starts midair and slingshots to the other side. I initially set an initial force on the player and set it to fall past the block with a disabled collider; that way, the player wouldn't suffer on the way down.
The swipe also took a bit of work to manage correctly; I had initially thought I could use deltaPosition, but it wasn't displaying values specific for upward and downward swipes, where each flipped in the specified direction. Luckily enough, just comparing the previous touch position to the current one in terms of only the y-direction allowed a simple and manageable swipe.
And that's another prototype complete - we've only got one more day of "rest" before the plans start rolling out, so I'll get to working on multi-touch controls soon.
No comments:
Post a Comment