As you see in the link above, the gate just passes through the box, which has the platformer and solid behavior.
This is the code for how the gate works. It uses a timer and lerp to move from one point to another. I attempted the same using moveto behavior, but it was just too buggy.
One option could be to detect if there's a box nearby the gate, and stop if so. However, this won't work for me. The gate should also be able to push a box upwards, and stop only when it hits the ceiling and can't move anymore.
Is there a better way to create this collision case?
Solid behavior will not help here - it only works with certain behaviors like 8direction or Platform. It will have no effect if you move the door by directly changing its position.
I would probably use MoveTo or Tween for the door movement. But you'll need to add events which to check for collision or overlapping with the box. And when the door collides with the box, stop it.
this still isn't good enough because like I said, I need the gate to be able to push the box upwards or to the side if nothing is blocking it from doing so.
Well, you'll need to program that.
When closing door collides with the box, check which direction the box can or cannot fly. Then either launch the box in that direction, or stop the door.
I think I didn't describe it right. I don't want the gate to launch the box out. The gate is basically a moving platform. Imagine it's going upwards, and there's a box on top of it.
How can I check which direction the box is able to go in?
I don't know your game, but you can probably check box position relative to the door - if it's above the door, move it with the door or even pin to the door.
Another option is to do all this with Physics, but this may turn out even more difficult.
Develop games in your browser. Powerful, performant & highly capable.
Just have it stop on overlapping, and move up till its no longer overlapping.