Advertisement
Guest User

Platformer2DUserControl

a guest
Feb 20th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. [RequireComponent(typeof(PlatformerCharacter2D))]
  4. public class Platformer2DUserControl : MonoBehaviour
  5. {
  6.     private PlatformerCharacter2D character;
  7.     private bool jump;
  8.  
  9.  
  10.     void Awake()
  11.     {
  12.         character = GetComponent<PlatformerCharacter2D>();
  13.     }
  14.  
  15.     void Update ()
  16.     {
  17.         // Read the jump input in Update so button presses aren't missed.
  18. #if CROSS_PLATFORM_INPUT
  19.         if (CrossPlatformInput.GetButtonDown("Jump")) jump = true;
  20. #else
  21.         if (Input.GetButtonDown("Jump")) jump = true;
  22. #endif
  23.  
  24.     }
  25.  
  26.     void FixedUpdate()
  27.     {
  28.         // Read the inputs.
  29.         //bool crouch = Input.GetKey(KeyCode.LeftControl);
  30.         #if CROSS_PLATFORM_INPUT
  31.         float h = CrossPlatformInput.GetAxis("Horizontal");
  32.         #else
  33.         //float h = Input.GetAxis("Horizontal");
  34.         #endif
  35.  
  36.         // Pass all parameters to the character control script.
  37.         character.Move( 1, false, jump );
  38.  
  39.         // Reset the jump input once it has been used.
  40.         jump = false;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement