Advertisement
Guest User

Platform.cs

a guest
Apr 15th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Platform : MonoBehaviour {
  5.  
  6.     public float heightToRaise = 5;
  7.     public float time = 5;
  8.     private bool up = false;
  9.  
  10.     void Start () {
  11.         StartCoroutine("Oscillate");
  12.     }
  13.  
  14.     void Update() {
  15.         transform.Translate(new Vector3(0,(up ? 1 : -1)*heightToRaise/time*Time.deltaTime,0));
  16.     }
  17.    
  18.     IEnumerator Oscillate() {
  19.         while(true)
  20.         {
  21.             up = !up;
  22.             yield return new WaitForSeconds(time);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement