Windows Seperate collision Masks with different behaviour ?

W

Wintermute()

Guest
Spent a few hours on this and looking online today...

I have a Boss sprite with 119 frames of animation ( I get a little obssessed with animation)

I want it to have a vulnerable spot for the killing shot. Thre are 7 frames of the 119 frame animation when the spot will appear on the belly of the mothership.

Ideally, I'd like to have a collision mask for the sprite where bullets just bounce off it. (the majority of the frames of animation) But for those 7 frames of the animation where the mothership shows it's vulnerable side (hehe), the bullet should have a different mask so it can score a hit on the spot (new collision mask) and kill the Boss (or weaken it)

Using the sprite editor in GMS, I can only seem to set seperate collision masks if I also select precise collision checking, and i don't seem to be able to change the position of the collision mask for different sub-images - wherever I set the mask, it wants to stay there.

Anyone have an idea for a workaround or what I am not seeing ???

thank you once again.
 

Mick

Member
I don't think you can change the bounding box for the collisions. One thing you can do is to set up a separate object and sprite for the vulnerable part of the boss. That object would move with the boss object and when the image_index of the animation is between the values where the boss is vulnerable, you check for collisions with the created object first to see if it's hit, if no collision there, you check the normal boss collision.
 
A

Aura

Guest
I'd personally not recommend changing the mask of the bullet for that purpose. There are better ways of doing that.

You could run an if statement checking if image_index of the mothership object is one of those seven images. If it is, cause damage and if it isn't, cause the bullet to bounce away.

Code:
if (image_index == 5 || image_index == 21 || image_index == 27 || image_index == 32 || image_index == 47 || image_index == 59 || image_index == 62) {
   //Inflict damage
}
else {
   //Cause the bullet to bounce away
}
 

Yal

🐧 *penguin noises*
GMC Elder
You could use the Alpha Threshold option + Precise Collisions, move the slider up to the max, and have all pixels other than the weak point be 254 alpha instead of 255 alpha on the vulnerable frames - the difference will be too subtle for the naked eye, but only the weak point will count for collisions on those frames since the 254-alpha pixels are too transparent to meet the threshold demands.
 
W

Wintermute()

Guest
You could use the Alpha Threshold option + Precise Collisions, move the slider up to the max, and have all pixels other than the weak point be 254 alpha instead of 255 alpha on the vulnerable frames - the difference will be too subtle for the naked eye, but only the weak point will count for collisions on those frames since the 254-alpha pixels are too transparent to meet the threshold demands.
Clever :) I'll fool around with the sprite editor a bit more to learn how to do that, but that is a cool idea.


I don't think you can change the bounding box for the collisions. One thing you can do is to set up a separate object and sprite for the vulnerable part of the boss. That object would move with the boss object and when the image_index of the animation is between the values where the boss is vulnerable, you check for collisions with the created object first to see if it's hit, if no collision there, you check the normal boss collision.
[Thy Sword is cool! I just downloaded and had a play. Great music too!]

Also an interesting solution... So to clarify - I would check the image_index of the Boss, create the instance of the vulnerable object at the x+y position of the Boss when the first index frame of the vulnerability appears, then destroy it on the last frame, then keep creating and destroying it every time ? Or would you just have the secondary object always travelling with the Boss ?

A bit unsure of the syntax to check the image index then create an object, i tried if image_index and if image_number but GMS is telling me that syntax is wrong. What wold be the correct syntax ?

Thank you to all who replied!
 
Last edited by a moderator:

Yal

🐧 *penguin noises*
GMC Elder
It's worth pointing out that GM's and operator is boolean and, not syntactical and. It's basically the binary counterpart to the * operator; just like multiplication, it operates on two values, not two expressions or two statements. That's why most people recommend using && instead since it's more abstract.
 
You can swap masks multiple times per step. It's all about how you use it I guess. Wouldn't be very handy for the collision event.
 

Yal

🐧 *penguin noises*
GMC Elder
If you're not even using collision events, it feels like it'd be easier using collision_sprite() than changing masks and then do place_meeting() checks since you don't need to worry about changing back masks and stuff... not sure which one is the faster, though, and it's just a matter of one line of code anyway.
 
W

Wintermute()

Guest
To clear it up a bit,

I'm using collision events, and my aim is for two things to happen when the end of level boss is fired on:

For all other parts of the boss than the vulnerable spot (which appears briefly during the 119 frame animation) i want the bullet to bounce off - when it hits the vulnerable spot, process damage.

So several bullets could be fired at the boss - some bouncing off, some hitting the vulnerable spot and i'd process the damage/health/death.
 
Top