How do i group clips together for collision detection?

because hitboxes go by the general size of a clip rather than the visuals of the clip, I have to have multiple clips for my game.

but in code, how do I group clips in order to make collision detection less of a nightmare?

and can I do it with an array?

this is the code i have written:

var Platforms = [“Platform”,“Platform2”,“Platform3”]
if (this.hits(Platforms)){
//this is meant to do nothing
} else {
gotoAndStop(1)
}

that gotoAndStop(1) is just there for me to know if it’s working or not.

and it obviously isn’t working.

any suggestions on how to make this work?

I don’t know exactly how it works but I think that 1.19.4 (test version) has something where you can do this.hits(mainClip.innerClip) or something like that to see if it hits a clip that is inside another.

but what about multiple clips unrelated to each other?

i don’t want to have individual hit codes for each clip (because there is going to be like, 10).

Well going off this you could have a for loop for each “Platform”

var Platforms = [“Platform”,“Platform2”,“Platform3”]
for (let clip of Platforms) {
    if ( clip.hits(thisOtherClip) ) {
        // do nothing
    } else {
        gotoAndStop(1)
    }
}

what’s “thisOtherClip”?

I guess depending on how your doing it you could be hit-testing the platforms against a clip (aka thisOtherClip) or you could run the code from thisOtherClip and have it something like

if ( this.hits(clip) ) {

my player character is just one sprite, so can i replace thisOtherClip with this?

So if you want to hit-test the player against every platform in the player clip script you could use something like this,

var Platforms = [Platform,Platform2,Platform3] // these should not be strings
for (let clip of Platforms) {
    if ( this.hits(clip) ) {
        // do nothing
    } else {
        gotoAndStop(1)
    }
}

hmm, your code does not seem to work for some reason.

:(

Here is an example of what I understand your looking for

My Project4-2-2022_11-59-15.wick (2.4 KB)

oh my god i just realized why my code isn’t working

when it cycle through the objects, some of them aren’t touching the player

so that’s why it doesn’t work.

now I have to redo it another way :(

EDIT: i tried to use the includes() function but it didnt work, heres my code:

const plats = [this.hits(plat),this.hits(plat2),this.hits(plat3)];
if (plat.includes(“null”,1)){
gotoPrevFrame();
}

@MooMooArmageddon, try not to use caps letters in your posts. Thank you.

Because your using const the values can’t change. So if you want it to work for more than one frame of the project you need to keep hit-testing.

Also if you send the .wick file I might be able to help a bit more.

I can’t send you the file, it’s too big (136.3 Mb!!)

and I’ve changed how I’ve done the collisions and stuff.

at this point, you should just give up on helping me and i should just make a new thread.

i’ve given up and i am just typing each individual detection.

now my project size is gonna bloat :(((

share the file by ufile.io

no

also i finished making the game