public void OnTriggerEnterCC2D(Collider2D other) { if (other.CompareTag(kWarpVolumeTag)) { ZMWarpVolume warpVolume = other.GetComponent <ZMWarpVolume>(); if (warpVolume != null) { transform.position = warpVolume.GetWarpPosition(_collider); } } }
void Start() { _forwardPrime = ComputeForwardPrime(); // Cast a ray along forward vector to find the most immediate warp volume. var dir = new Vector2(_forwardPrime.x, _forwardPrime.y); var casts = CheckDirection(dir); for (int i = 0; i < casts.Length; ++i) { ZMWarpVolume checkSibling = casts[i].collider.GetComponent <ZMWarpVolume>(); // (Could add transform forward check). if (checkSibling != null && checkSibling != this) { // Found the sibling volume. _sibling = checkSibling; } } }