Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Platform : MonoBehaviour {
- public float heightToRaise = 5;
- public float time = 5;
- private bool up = false;
- void Start () {
- StartCoroutine("Oscillate");
- }
- void Update() {
- transform.Translate(new Vector3(0,(up ? 1 : -1)*heightToRaise/time*Time.deltaTime,0));
- }
- IEnumerator Oscillate() {
- while(true)
- {
- up = !up;
- yield return new WaitForSeconds(time);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement