I’ve got a problem with an enemy sprite that needs to collide with two trigger objects, one to apply force in one direction and the other to apply a force in the other direction.
The enemy in question has multiple instances active at the same time, (10+) and I want it to first change animation to “wondering” then when the animation is over it should switch to the “moving” animation, apply the force needed for that direction and after reaching the next trigger object it should repeat all that and go in the opposite direction.
The problem is that after it spawns it does its “Wondering” animation, turns around(if needed) and goes the way it’s supposed to, but once it reaches the other trigger object it just moves past it and falls down the platform.
This is the what i’ve done and it works perfectly with a single enemy on the scene, but if they are the intended number of enemies (10+), the problem i mentioned earlier occurs.
I’ve tried many things, and the closest i came to solving my problem was when they were acting how they were supposed to, but when i started moving they just stopped at the next trigger object. Sadly i can’t recreate it again after trying for more than an hour so i can’t show a picture of that “success”.
I also have 4 other types of enemies with simillar numbers (10+) and they are all working fine, the only reason i can see for this one not working is the fact that it’s changing animation and i have no idea how to fix it.
Both of the animations are the same pixel size canvas and the body of the enemy is pretty simple, it just turs left and right as if it’s going “where do i go next”.
I’ve added the animation sprites in the picture too in case that helps.
I believe the issue is being caused by the "Trigger once while true" conditions. You can safely remove all of them. After doing that, add the condition "The animation of SlidingRock2 is 'SlidingRockWondering'" to both the second and last events in the screenshot.
Sadly it did not work, i added the “SlidingRockWondering” to both the second and the last event and removed the “Trigger once” conditions and the resoult was that the enemies that started on the right side did their “wondering” animation and went to the left side where they got stuck doing the “wondering” animation along with the enemies that were stuck there doing the same animation from the start.
I also tried several other things:
“Trigger once” on the 1st and 3rd events, the 2nd and 4th events and on all 4. No luck.
“For each object” for 1st and 3rd events, the 2nd and 4th events and on all again, No luck.
-Tried adding “Trigger once” on the “For each object” for 1st and 3rd, 2nd and 4th and all 4 at once again, No luck there either.
I’ve spent 8 hours today trying to figure this out with the help of google and nothing works.
Gonna give it a go tomorrow as well, hopefully a fresh brain works better
Then try adding the action "Separate SlidingRock2 and Move_Left" to the first event, and the action "Separate SlidingRock2 and Move_Right" to the third event.
Ok, so the “Separate SlidingRock2 and Move_Left/Right” actions to the first and third events made it all work, there was still one issue left though, the animations were repeating before turning back.
When the enemy reached a trigger point it changed to “Wondering” then to “Moving” then to “Wondeing” again and on the second time it changed to “Moving” it actually started moving how it was expected to.
Figured this must be the Collision masks screwing up with the collision because when the rock flips horizontally, the mask shifts slightly backwards due to the shape of it not being symmetrical. (See the “SlidingRockWondering” animation pictures on the pic i uploaded)
Since i did not want my Bullets to be hitting the small rocks, i had made it so that they an only hit the big one and that’s where the issue was coming from.
I changed the collision mask to include only the furthest forward facing rock (basically to the edge of the sprite canvas) and i made it so that it’s short enough so my bullets can fly past it and collide with the big rock.
Having done that, things started working as expected with my original “code” with the exception that the “Trigger once” made them ignore collisions after their first collision, but i removed those as well and now everything is working perfectly.
Thank you for helping me understand what the issue was and the importance of symmetry when changing animations while colliding with an object.
All is good now and I can continue with my project, much obliged kind sir.