void WhileColliding() { // Adjust flickering bug, not completely solved tho if (!hasCollided) { return; } bool isInFront = GetDeviceInFront(); if ((isInFront && !wasInFront) || (wasInFront && !isInFront)) { portalManager.EnterPortal(); } wasInFront = isInFront; }