-
1 Attachment(s)
Okay, so I'm still having some problems with these.
Attachment 22910
I'm using the method where I compare positions to determine whether or not I am colliding, and it works great!
EXCEPT, it only works when there is only one instance of the object the player is colliding with. I realize this is due to the object scoping somehow, because the code only works if the condition is true for "all objects". However, I just can't seem to figure out how to get around it. I tried having a fastloop for each instance of the moving platforms and giving them IDs, and then comparing the ID to the loopindex when testing the positions but this did not work.
I then tried to reverse the detection, asking if the platform was overlapping the player instead but that didn't work either. I then tried adding an additional criteria that one of the players detectors that is not used in normal collision is overlapping the moving platform, but that resulted in the overlap-condition overriding everything and ignoring the positioning conditions. Why would it do this? Any ideas how to work with this?
-
Seems like there's a problem with the attachment, was it the .mfa?
Can you try reupload?
From what you describe it's very likely a scoping issue, as you say!
-
I added an image of what the code looks like ,should be visible now!
Any idea of how I get around the object scoping?
I'm mostly perplexed of why it completely ignores the X,Y conditions when I add another selector condition.
-
If my eyes don't bug me you're checking against a qualifier,
so I suppose you have multiple of (qualifier) object
and they are in "side B" of comparison
that won't work unless you put those conditions inside a "foreach" loop for the qualifier
this alone could not be the solution, but it's hard to tell just from that image,
if you need further help it would be very useful if you could isolate the not-working code in a new mfa to upload here
-
Thank you for the answer schrodinger! I tried changing the qualifier reference to checking towards the object itself, but that did not solve the problem either. Do I have to put direct object references inside a foreach loop as well?
-
yes, if you have multiple of those objects
if you have a comparison:
alt.val.X (player) < (object) right edge
etc.
and you have multiple "object"
but you need to specifically check each single object (as in this case for all four boundaries)
you need to specifically scope second term of comparison
by filtering a single "object" (which you don't need to do)
or, with a foreach, by "cyclically" filtering each single "object" (this is what you need to do)
as a quick test, you can simply try
always >>>
start loop foreach (qualifier)
and put:
on each (qualifier)
on top of your collision testing conditions above
but again, no warranty this alone would work XD
at least not without clearly seeing all the code involved
-
Hm, I tried scoping using a forEach loop and a regular loop but it did not work. I'll try and make an mfa example and upload it.
-
1 Attachment(s)
Attachment 22911
Here, I added an example of the issue! You can click on a red square to delete it, and you'll notice that the collision then works.
Somehow, if I remove the Y axis comparison it also works. I do not know why this is. Any ideas?
-
Note: If I have several objects that share the same qualifier but are not the same object, it works. If there are more than one of the same object in the qualifier group, it does not work.
-
1 Attachment(s)
Back again - here's a modified version:
Attachment 22917
now you should just need to add vertical movement / vertical collision
Btw, there's a slightly subtle issue when moving elements by integer vs floating point amounts,
since the platform was moving with trig code, it could have moved by some "float" amount
while the player is constantly moving at "integer" 1 pixel steps
this results in some inconsistencies you could solve in (at least) two ways:
1) checking all boundaries as float amounts (by storing all edges floatpositions, or object center floatposition +/- halfwidth/halfheight of both platform and player)
with this you'll get high precision you can't take advantage of coordinate checks and Xright/Xleft (integer)
2) in the file I went with this one because it's the first I thought of XD, trimming the X movement of both platform and player (which already was) to just integer movements
if you don't do this, you get small overlaps/jaggyness due to rounding from two different positions
Not sure I phrased it well enough to be clear,
anyway, if you have other issues, let us know :)