Advertisement
CakeMeister

Groundcheck update phan 20 extra

Jul 17th, 2017
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GroundCheck : MonoBehaviour
  6. {
  7.  
  8.     public Player player;
  9.     public MovingPlat mov;
  10.  
  11.     public Vector3 movep;
  12.  
  13.     // Use this for initialization
  14.     void Start()
  15.     {
  16.         mov = GameObject.FindGameObjectWithTag("Movingplat").GetComponent<MovingPlat>();
  17.         player = gameObject.GetComponentInParent<Player>();
  18.     }
  19.  
  20.  
  21.     void OnTriggerEnter2D(Collider2D collision)
  22.     {
  23.         if (collision.isTrigger == false)
  24.             player.grounded = true;
  25.     }
  26.  
  27.     private void OnTriggerStay2D(Collider2D collision)
  28.     {
  29.         if (collision.isTrigger == false || collision.CompareTag("water"))
  30.             player.grounded = true;
  31.         if (collision.isTrigger == false && collision.CompareTag("Movingplat"))
  32.         {
  33.             movep = player.transform.position;
  34.             movep.x += mov.speed* 1.3f;
  35.             player.transform.position = movep;
  36.         }
  37.            
  38.     }
  39.  
  40.     private void OnTriggerExit2D(Collider2D collision)
  41.     {
  42.         if (collision.isTrigger == false || collision.CompareTag("water"))
  43.             player.grounded = false;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement