Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class ObjShieldBubble : ObjShield {
  4.     string[] buttonsJump = new string[] { "Secondary", "Tertiary" };
  5.     public bool used = false;
  6.  
  7.     void Update() {
  8.         // Movement
  9.         if (character.InStateGroup("ground")) {
  10.             if (used) {
  11.                 character.GroundSnap();
  12.  
  13.                 if ((character.forwardAngle < 45) || (character.forwardAngle > 360 - 45)) {
  14.                     SFX.Play(audioSource, "sfxShieldBubbleJump");
  15.                     animator.Play("Bubble Rebound");
  16.                     Vector3 slopeVelocity = transform.up * 7.5F * character.physicsScale;
  17.                     slopeVelocity.x *= 2;
  18.                     character.velocity += slopeVelocity;
  19.                     character.position += character.velocity / 60F;
  20.                     character.stateCurrent = "jump";
  21.                 }
  22.  
  23.             }
  24.             used = false;
  25.             return;
  26.         }
  27.         if (used) return;
  28.         if (!character.InStateGroup("jump")) return;
  29.         if (!character.input.GetButtonsDown(buttonsJump)) return;
  30.         if (character.stateFrameTimer == 0) return; // Hack?
  31.  
  32.         used = true;
  33.         Vector3 velocityTemp = character.velocity;
  34.         velocityTemp.y = -8F * character.physicsScale;
  35.         velocityTemp.x *= 0.5F;
  36.         character.velocity = velocityTemp;
  37.         SFX.Play(audioSource, "sfxShieldBubbleJump");
  38.         animator.Play("Bubble Bounce");
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement