So here is the scenario: I have an active object that I use as a sensor on another object. If the main object is moving down and the sensor overlaps a backdrop, I have an event that tells it to Stop, and set Y position to Y (main object) -1 to make it move back up. The problem is, say the main object is falling, and it falls fast. When the sensor overlaps, it could be 10 pixels deep by the time it stops, then as it's overlaping it's setting the Y position to Y-1 and slowly moves up.
I'm wondering if there is a way to make it instantly back up so it's not overlapping anymore via fastloop or another method? I used a fastloop and I can start a loop for X number of loops, but there's no way to really figure out how many loops to do it for, because the depth of the overlap varies depending on the speed of the object.
Does this make sense? I'm really hoping to find a way around this! Thanks
Bah, had a good example, cant find it now though, but, yeah, basically you do that. assuming you're using objects for collision detection about a character for a static movement engine. Like a single pixel object set at his feet that detects if his feet it the floor.
basically it's like:
detector overlaps background:start loop
on loop: move up 1 pixel
+ object is no longer overlapping: end loop
So I just tried that exactly how you wrote here, and it didn't work...if I put start loop 1 time, it acts exactly the same as before. If I enter an arbitrary amount, say, start loop 100 times, any time it detects an overlap, it shoots the object up 100 pixels, even with the on loop + not overlapping event... is there something missing?
an example, doing quite literally what i said above object starts in the block, and as soon as events happen, it is shifted up and pushed out. loop ends when it no longer overlaps backdrop with the stop loop command, thus stopping it rising.
if you still have problems, upload what you got and ill take a look at it.
Yeah, that's exactly how I have it set. I think MMF is doing one of those things where it just doesn't work right. It's happened many times to me. Usually it involved me having to delete all the related objects and recoding everything. Maybe this will just be the end of my engine I'm going to maybe rebuild it again at some point, but as of this minute I'm ready to pull my hair out from frustration...
Yeah, I have it in the right order. I've had stuff like this happen before in C&C and MMF 1.5. I would've hoped that it was fixed in developer... oh well. At least now I know the right way to do it and how to do it, so when I go back through and re-do stuff I'll know it from the beginning
On loop "move object"
+ object overlapping backdrop
move object in opposite direction by 1 pixel
start fastloop "move object"
so the loop keeps calling itself until the additional conditions on the loop are false. Then you don't have to worry about stopping it. Though to be honest, I have really turned against using arbitrary number of loops to push objects back/on top of platforms. I would rather move the objects using fastloops 1 pixel at a time, and if an overlap occurs after a pixel move in either direction, simply undo the last movement, though this is less efficient as you are making more collision tests per code loop...
well, I suppose the quickest and most efficient method would be to move the object in chunks(minimum size the player could move without hitting new obstacles,say,height of the player active) until its out of the obstacle, and then binary cut the final chunk moved to find the correct position.
But, that's perhaps a bit over the top a solution.