private void Start() { m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Rigidbody2D.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher>(); } //Allow to make platform only move when they became visible Renderer[] renderers = GetComponentsInChildren <Renderer>(); for (int i = 0; i < renderers.Length; ++i) { var b = renderers[i].gameObject.AddComponent <VisibleBubbleUp>(); b.objectBecameVisible = BecameVisible; } //we make point in the path being defined in local space so game designer can move the platform & path together //but as the platform will move during gameplay, that would also move the node. So we convert the local nodes // (only used at edit time) to world position (only use at runtime) m_WorldNode = new Vector3[localNodes.Length]; for (int i = 0; i < m_WorldNode.Length; ++i) { m_WorldNode[i] = transform.TransformPoint(localNodes[i]); } Init(); }
void Awake() { if (platformRigidbody == null) { platformRigidbody = GetComponent <Rigidbody2D>(); } if (m_Collider == null) { m_Collider = GetComponent <Collider2D>(); } m_ParentCatcher = null; Transform currentParent = transform.parent; while (currentParent != null) { PlatformCatcher catcher = currentParent.GetComponent <PlatformCatcher>(); if (catcher != null) { m_ParentCatcher = catcher; } currentParent = currentParent.parent; } //if we have a parent platform catcher, we make it's move "bubble down" to that catcher, so any object caught by that platform catacher will also //be moved by the aprent catacher (e.g. a platform catacher on a pressure plate on top of a moving platform) if (m_ParentCatcher != null) { m_ParentCatcher.m_MoveDelegate += MoveCaughtObjects; } }
private void Reset() { //we always have at least a node which is the local position localNodes[0] = Vector3.zero; waitTimes[0] = 0; m_Rigidbody2D = GetComponent <Rigidbody2D>(); m_Rigidbody2D.isKinematic = true; if (platformCatcher == null) { platformCatcher = GetComponent <PlatformCatcher> (); } }