I created a wall that can be opened and closed, and another object that can be moved using a lever.
If I stop the moving object at the position where the wall can be opened or closed, and then open the wall, the collision randomly pushes the moving object to a certain position.
Could you please advise on how to effectively and reasonably solve this problem?
Initially, I added a check to the moving object: if it gets stuck inside the wall → move it 50 pixels along the X-axis.
However, after setting this up, it seemed to have no effect. The object is still being squeezed and pushed away. I’m not sure where I went wrong, so I came to the forum for help!
I’m ashamed to admit I have no idea what this feature is supposed to do
I just went ahead and enabled it to test, but it still doesn’t get pushed away or flung off. It seems to make absolutely no difference compared to when it was disabled.
It has two ways of working, picked with the first option, Who Moves.
Push Others goes on the wall. Put it on a state that runs right before the state where the wall’s collision turns on. When that state runs it checks what’s overlapping the wall’s collision shape and moves it out of the way in the same frame, so the physics engine never gets the chance to shove it. This is the one I’d try first for your setup since it’s the most reliable.
Push Self goes on the moving object instead. In any state where it might get stuck, it checks every frame whether it’s inside a wall, a tile, or another solid object and steps itself out. This one is racing the engine’s own push though, so if you still see the object jump first and then settle, use Push Others on the wall instead.
Push Direction picks which way things get moved. Nearest picks the shortest way out, or you can force left, right, up, or down.
Push Padding is the gap left between the object and the wall edge after it’s moved, not how far it travels, so 2 or 3 is usually enough.
To test it with your wall:
On the wall object, add a new state between your open state and your closed state. Have it transition to the closed state after 1 frame or with a 0 second Elapsed Time.
Add Baz Eject Overlap to that new state, Who Moves set to Push Others, Push Direction set to whatever makes sense for the wall, for example Push Left for a wall closing from the right.
Move your object into the wall’s spot with the lever, then close the wall. The object should land just outside the wall on the side you picked, every time.
If your wall turns its collision on inside the same state as the open to close animation, that’s what the extra state is for, the eject has to happen before the collision exists.
I’m so incredibly grateful to Mr. Baz! I ran a test. The failure might have been due to some operational error on my part.
I couldn’t select my own group in the target group selection. However, this shouldn’t matter; I selected “All” (the default). In my “Wall Activation” animation, the collision box is inactive for the first few frames and only becomes active in the final frame.
I added Push Others to this action, but during testing, I was still pushed away by the collision.
So, I tried adding a new action in the middle of the activation sequence specifically for detection, as you suggested, but I was still pushed away
I’d like to ask how the “Push Others” action detects other collision boxes. For example, if a wall has no layer 1 mask and the moving object also has no layer 1 mask, would that work? I tested it, but there was no response. Please give some guidance, baz.
I also tested “Push Self” and it produced an effect, but every time I open the wall, it moves on its own. As a wall object, it doesn’t get stuck anywhere, yet it still moves in the air. Every time I close and then open it, it shifts a certain distance.
Quick question, with the mismatched masks, did the wall still shove the object? And where exactly did he put Push Others (which state, and does the wall box live on the last frame of that same state’s animation)?
S.C, sorry for the trouble, both of those were on my end. The version you tested only looked at the wall box when it was already turned on, and the AGM animation editor keeps the wall box off until the last frame, so it never saw anything to push. I’ve fixed that and also changed the timing, it now reads the wall’s own animation and pushes right before the box turns on instead of the moment the state starts. Updated file attached, just replace the one in custom_actions. BazEjectOverlapAction.gd (37.0 KB)
For Push Others, put it on the same state that plays the closing animation, no extra state needed anymore. The only thing it needs is the wall box being off on that animation’s first frame, which is what you already have. Push Self goes on the object that gets stuck instead, in any state, and it now steps out of a wall that’s about to close as well as tiles and things that are already solid.
On the masks, it uses the same layers and masks the collision itself uses, there’s no layer 1 requirement. If neither side’s mask sees the other’s layer, they’d never collide in the first place so there’s nothing to push. If you still got shoved with mismatched masks, let me know, that would be something different.
The wall drifting with Push Self was my bug, a mask of 0 made it treat everything as solid. That’s fixed too, though Push Self is meant for the moving object rather than the wall. The group dropdown only lists the default groups for now, All Group works fine, I’ll look at custom groups next.
Reporting to Baz: Even after replacing with the new version, the object is still being pushed away as before. I failed to successfully implement the X-axis translation of the moving object.
Here you can see my wall animation. The first frame of the collision box is enabled, while subsequent frames have it disabled.
Both my action’s enable and disable states use this animation. For the wall blocks, when disabled, it plays normally. When enabled, it plays the animation in reverse.
Your action is placed within the reverse-play action for the enabled state. It failed. This means the animation frame where the collision box is enabled is the last frame.
Thanks for the screenshot, that was the missing piece. The version I sent only understood the wall animation playing forward, and your closing state plays it backward, so it never saw the box coming and did nothing. I rebuilt your setup here, box on at the first frame and off after, played in reverse, and the new file pushes the object out right before the box turns on. The wall stays put too. Same fix applies to Push Self if you’d rather put it on the moving object.
Your layers and masks are fine as they are, layer 2 on the wall with mask 2 on the moving object is exactly the pairing it looks for, so nothing to change there.
Updated file attached, replace the one in custom_actions and keep the action right where you have it, inside the enable state. If it still shoves after this one, could you send the wall object’s scene so I can run it directly?
Reporting back: I placed the action on the brick wall under “Push Others,” but it still failed.
I then attached the action to a moving object to make it “Push Self.” It succeeded once, but this was random; subsequent attempts failed repeatedly, with the object being squeezed and pushed away. Perhaps the judgment depends on the position?
I am providing the .tscn and .vs files for both the brick wall and the moving object. Both switch forms using two switches.
Testing with an empty scene works fine! (You may need to reset the global switches in a new scene.) Moving Object.zip (4.7 KB) switch_brick.zip (4.0 KB)
I just remembered that if baz still has the scene I sent via email, testing can be done directly in there.
I hate to ask this but could you send a fresh project with this exact situation ready to test to pgmmv-support@gotchagotcha.jp? That would be the easiest way for me to look into what your situation would best need and edit the action accordingly. I’m super busy at the moment and this would expedite things tremendously.
I’ve noticed you haven’t replied for a while, so I’ve pretty much figured out what you’re trying to do. I’ve created a mini version to reproduce the issue.
The brick walls can be toggled open and closed by pressing Z, and your plugin has already been loaded.
Simply move the character to the brick position and open it to test. Push Others_demo.rar (4.3 MB)
Due to forum storage limits, this archive is double-compressed.
Thank you so much for your help; the non-compressed translation effect has been successfully implemented!
I was wondering if the reason it was being compressed to the top-left corner is because the brick wall is composed of multiple small square collision boxes. This might cause multiple square collision boxes to simultaneously detect the need to move the object when it embeds, leading to instability in the object’s moved position. Would changing it to a single vertical bar collision box improve this and prevent random bouncing? (I’ll go test it.)
It’s my fault for not providing sufficiently detailed information.
I just ran a test, and if the collision boxes are monolithic, the random squishing and bouncing off won’t occur even without using Baz’s plugin.
AGM’s own collision ejection is very intuitive: it slides out in the direction of the edge it’s approaching.
I see now. The phenomenon of random squishing and bouncing only happens when an object is within multiple collision boxes. The only way to stabilize this behavior is to rely on your plugin. It seems that the plugin’s current groups are not mapped to the project; it would be better if they could correspond to real groups.