Advertisement
movethebongos

Update

Aug 22nd, 2017
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. //If the player is stuck to a wall and is supposed to still be stuck to the wall
  2. if (timeToWallUnstick > 0 && stuckToWall) {
  3.  
  4.     //If the player hasnt landed yet
  5.     if (!characterController.isGrounded) {
  6.  
  7.         //Make the player fall at half gravity
  8.         speed.y = verticalVelocity / 2;
  9.  
  10.         //make sure the player cant leave the wall
  11.         speed -= forbiddenMove;
  12.     }
  13.  
  14.     /*
  15.     Tick down the time the player has to be "stuck" to the wall
  16.     (counts down from a preset value of 0.25 of a second)
  17.     */
  18.     timeToWallUnstick -= Time.deltaTime;
  19.  
  20.     /*
  21.     Make sure to have some leway so the player can perform the double jump
  22.     even though they might have left the wall a few fractions of a second
  23.     */
  24.     timeToWalljumpleway -= Time.deltaTime;
  25.  
  26. } else {
  27.     /*
  28.     If the player isnt supposed to be stuck to the wall anymore, like if
  29.     the timer has run out. make sure to "unstick" from the wall and reset
  30.     the timer back to its original value (0.25 of a second)
  31.     */
  32.     timeToWallUnstick = wallStickTime;
  33.     stuckToWall = false;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement