MovingPlatform
/**
* Add to a moving platform, along with a Box Collider for
* trigging only when an object is on top of the platform.
* */
using UnityEngine;
using System.Collections;
public class MovingPlatform: MonoBehaviour {
// TODO: Add objects on platform to an array.
// Save old parent on enter, reattach old parent on exit.
void OnTriggerEnter(Collider other) {
other.transform.parent = gameObject.transform;
}
void OnTriggerExit(Collider other) {
other.transform.parent = null;
}
}
Recent Comments