Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (controlState.IsKeyDown(Keys.W))
- {
- /// Rev: Example, playerVelocityAdd appears to be the direction
- /// the 1 would be how many units you want to try and push
- Physics_AddForce(DEFAULT_MASS, 100, playerVelocityAdd, DEFAULT_FORCE, playerVelocity);
- }
- player.updatePosition(playerVelocity); //Update player position with determined velocity and speed modifier
- playerVelocity *= 0.95f; //Reduce velocity every frame (inertia)
- }
- protected void Physics_AddForce(float mass, float add, Vector3 direction, float force, Vector3 velocity)
- {
- float push;
- //Determine what to add on to the force
- push = force * (add / mass); //Add = How many units to move from the force, like playerVelocityAdd
- //[COLLISION] The speed the player is sent backwards
- velocity += (direction * push); //Final new velocity taking into account the direction and how much to move forwards (push)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement