Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1.             if (controlState.IsKeyDown(Keys.W))
  2.             {
  3.                 /// Rev: Example, playerVelocityAdd appears to be the direction
  4.                 /// the 1 would be how many units you want to try and push
  5.                 Physics_AddForce(DEFAULT_MASS, 100, playerVelocityAdd, DEFAULT_FORCE, playerVelocity);
  6.             }
  7.             player.updatePosition(playerVelocity); //Update player position with determined velocity and speed modifier
  8.             playerVelocity *= 0.95f; //Reduce velocity every frame (inertia)
  9.         }
  10.  
  11.         protected void Physics_AddForce(float mass, float add, Vector3 direction, float force, Vector3 velocity)
  12.         {
  13.             float push;
  14.             //Determine what to add on to the force
  15.             push = force * (add / mass); //Add = How many units to move from the force, like playerVelocityAdd
  16.                                        //[COLLISION] The speed the player is sent backwards
  17.             velocity += (direction * push); //Final new velocity taking into account the direction and how much to move forwards (push)
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement