Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class platform : MonoBehaviour {
- private void OnCollisionStay2D(Collision2D collision)
- {
- if (collision.collider.CompareTag("Player"))
- {
- if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
- gameObject.GetComponent<Collider2D>().enabled = false;
- }
- }
- private void OnCollisionExit2D(Collision2D collision)
- {
- if (collision.collider.CompareTag("Player"))
- {
- Invoke("Restore", 0.5f);
- }
- }
- void Restore()
- {
- gameObject.GetComponent<Collider2D>().enabled = true;
- }
- }
Add Comment
Please, Sign In to add comment