Advertisement
CakeMeister

MovingPlat phan 7

Jun 29th, 2017
1,136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MovingPlat : MonoBehaviour {
  6.  
  7.    
  8.     public float speed = 0.05f, changeDirection = -1;
  9.     Vector3 Move;
  10.  
  11.     public PauseMenu pausep;
  12.    
  13.     // Use this for initialization
  14.     void Start () {
  15.        Move = this.transform.position;
  16.      
  17.         pausep = GameObject.FindGameObjectWithTag("MainCamera").GetComponentInParent<PauseMenu>();
  18.     }
  19.    
  20.     // Update is called once per frame
  21.     void Update () {
  22.         if (pausep.pause)
  23.         {
  24.             this.transform.position = this.transform.position;
  25.  
  26.         }
  27.         if (pausep.pause == false)
  28.         {
  29.             Move.x += speed;
  30.             this.transform.position = Move;
  31.         }
  32.      
  33.      
  34.        
  35.     }
  36.  
  37.     private void OnCollisionEnter2D(Collision2D col)
  38.     {
  39.         if (col.collider.CompareTag("Ground"))
  40.         {
  41.             speed *= changeDirection;
  42.         }
  43.  
  44.      
  45.  
  46.     }
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement