MovingPlatform
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/** * 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