GibTreaty

Bawl Physics Simple Input

Jul 20th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. namespace YounGenTech.BawlPhysics {
  4.  
  5.     /// <summary>
  6.     /// Simple input for rolling and jumping.
  7.     /// </summary>
  8.     [AddComponentMenu("Bawl Physics/Input/Simple Input")]
  9.     public class BawlPhysicsSimpleInput : MonoBehaviour {
  10.  
  11.         Jump _jump;
  12.         Roll _roll;
  13.  
  14.         public Jump JumpAbility {
  15.             get {
  16.                 if(!_jump) _jump = GetComponent<Jump>();
  17.  
  18.                 return _jump;
  19.             }
  20.         }
  21.  
  22.         public Roll RollAbility {
  23.             get {
  24.                 if(!_roll) _roll = GetComponent<Roll>();
  25.  
  26.                 return _roll;
  27.             }
  28.         }
  29.  
  30.         void Update() {
  31.             if(RollAbility) {
  32.                 RollAbility.StartAbilityHorizontalAxis(Input.GetAxis("Horizontal"));
  33.                 RollAbility.StartAbilityVerticalAxis(Input.GetAxis("Vertical"));
  34.             }
  35.  
  36.             if(JumpAbility) {
  37.                 if(Input.GetButtonDown("Jump"))
  38.                     JumpAbility.StartAbility();
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment