maxhacker11

One Way Platform Code

Jul 24th, 2023
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | Source Code | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class DropDown : MonoBehaviour
  6. {
  7.     public string oneWayPlatformLayerName = "OneWayPlatform";
  8.     public string playerLayerName = "Player";
  9.  
  10.     private void Update()
  11.     {
  12.         if (Input.GetAxis("Vertical") < 0)
  13.         {
  14.             Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer(playerLayerName), LayerMask.NameToLayer(oneWayPlatformLayerName), true);
  15.         }
  16.         else
  17.         {
  18.             Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer(playerLayerName), LayerMask.NameToLayer(oneWayPlatformLayerName), false);
  19.         }
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment