Wednesday, January 15, 2014

Week 5 Day 3 - Physics my friend, We are the master now!

So we found out what our problem was with the push ability.  The problem that we perceived we had was that for no reason the force from the push would send the player flying straight up into the air, with only a little horizontal force.  The problem that we actually had was the way we were handling movement.

In our movement script every frame we were checking if the player was attempting to move, and subtracting our target velocity (0 if the character wasn't trying to move) from our current velocity.  So if we were still and the character was trying to move, we would start moving, and if we stopped trying to move, the character would be slowed down to a velocity of 0.  This means that every time we applied a force to that character, the next frame they would be slowed down to a stop.  However, we were handling jumping (movement in the vertical direction) differently.

Therefore in actuality, the vertical movement wasn't the problem, and the horizontal movement was.  When we saw that our push ability didn't move the character very far, we vastly increased the force at which we were applying the ability.  This made the forward movement seem a little more correct, but insanely increased the vertical force.

Our solution was to revamp the way we were doing movement, and not push the player to a stop any longer.  This means we now have to rely on actual physics for the character to come to stop, such as air drag and friction.  After readjusting some values our movement is back to normal, and we finally feel comfortable with our push ability.

We have the following variables that we can adjust to modify the finer movement mechanics of how the game runs:

  • Gravity
  • Static Friction
  • Dynamic Friction
  • Air Drag/Resistance
  • Bounciness (we have not messed with this yet)
We still have an issue with how we are respawning players and the game ending.  Currently, each client waits three seconds before trying to respawn their character, and if the game is over, they destroy their game object instead.  However, if the game were to end, and a new game start in that three second time period, the game object wouldn't ever be destroyed.  We would then have multiple game objects on one client, along with multiple cameras and strange things begin to happen.

Overall we feel pretty good about where we are, in relation to how far away our first alpha test will be.

No comments:

Post a Comment