• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Change collision depending on the sprite (GMS 1)

Hi there! We are trying to change the collision of an object, depending on the sprite it is using. We want to use this as we have bullets that can move horitzontally and vertically.
Our object uses physics and has a collision defined, in the physics properties "tab". It uses phy_bullet = true, and due to ?? reason, "image_angle" does not work (but we solved that by changing the sprites on each situation; this is not a problem).
The main problem then, is that we wanna change the collision if the bullet (arrow, right now) is going down, which has to be different that the one that goes horitzontal (arrow_down.png| arrow_right.png). As well we will want to change the bullet to maybe rocks, spells,... Is there a way to do what we want? We tried using the collision masks, but:
1) even though we've searched information, we do not know how to use it (properly).
2) when we tested (maybe we did it wrong) it didn't work. We think that that is due to we set the collision in the object's physics properties.

Any ideas?? Thank you very much!!
 
let's assume you have the two srpites named spr_bullet_horizontal and spr_bullet_vertical.
Shouldn't this code in collision event work for you?:
Code:
If (sprite_index == spr_bullet_horizontal) {
    // do "horizontal" collision
} else {
    // do "vertical" collision
}
Or did I misunderstand the question?
 
let's assume you have the two srpites named spr_bullet_horizontal and spr_bullet_vertical.
Shouldn't this code in collision event work for you?:
Code:
If (sprite_index == spr_bullet_horizontal) {
    // do "horizontal" collision
} else {
    // do "vertical" collision
}
Or did I misunderstand the question?
Not at all,... Our collision is set in the object (uses physics, and then the physics tab pops up and we set the collision there).howw.png collisionss.png
We want what's above, but we don't know how,... It would be something more like a "hitbox", instead of collision... It's true that we didn't explain well...
 
Ah. I thought you had to change the collision event based on sprite. If it's just about the collision mask I think you could make a new fixture and apply it by code. But it seems to me you don't need all that hassle. you can just turn the whole bullet object when firing and the collision mask will turn with it.

I made a short example and uploaded it to my drop-box. Check if that's what you want to accomplish:
https://www.dropbox.com/s/up0b97z5ea9f4jo/Physics_turn_bullet.gmz?dl=0
 
Top