CakeMeister

platform jump down phan 22 extra

Jul 23rd, 2017
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class platform : MonoBehaviour {
  6.  
  7.  
  8.     private void OnCollisionStay2D(Collision2D collision)
  9.     {
  10.         if (collision.collider.CompareTag("Player"))
  11.         {
  12.             if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
  13.                 gameObject.GetComponent<Collider2D>().enabled = false;
  14.         }
  15.     }
  16.  
  17.     private void OnCollisionExit2D(Collision2D collision)
  18.     {
  19.         if (collision.collider.CompareTag("Player"))
  20.         {
  21.             Invoke("Restore", 0.5f);
  22.         }
  23.     }
  24.  
  25.     void Restore()
  26.     {
  27.         gameObject.GetComponent<Collider2D>().enabled = true;
  28.     }
  29. }
Add Comment
Please, Sign In to add comment