• 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!

Legacy GM Help with too late collision, please!

E

Edwin

Guest
So I have a bullet object and wall object.
When bullet collides with wall object (especially when player are near the wall), it passes through the wall and disappears (destroys). How to fix such a long time collision?

bullet object:

WALL OBJECT COLLISION:
Code:
speed = 0;
sprite_index = spr_bullet_death;
ANIMATION END:
Code:
if (sprite_index = spr_bullet_death) {
    instance_destroy(id);
}

wall object:
"he get nothing. he lose. good day, sir"

So I have this:
 

DesArts

Member
When it collides maybe check the direction of the bullet and set its final position accordingly. For example if it's going mostly left and hits a wall, set it's position to the right of that wall as it dies.
 
E

Edwin

Guest
When it collides maybe check the direction of the bullet and set its final position accordingly. For example if it's going mostly left and hits a wall, set it's position to the right of that wall as it dies.
Wouldn't it look weird and twitchy because of this?
 
E

Edwin

Guest
When it collides maybe check the direction of the bullet and set its final position accordingly. For example if it's going mostly left and hits a wall, set it's position to the right of that wall as it dies.
Thanks! I made it and it looks pretty good, but somewhy when player is close to the wall it spawns inside of the block, but I can accept it. Thanks again!
 

DesArts

Member
If it spawns inside the wall perhaps that should also be another trigger to do the exact same thing in the create event? Might be tougher to pull that off though - to get 100% always perfect results you'd want to design your own custom collision system and well, that's not easy haha. Good luck!
 

Morendral

Member
You can always do a collision check before it moves, and the length it is going to move. For instance, if your wall is an object, do a collision_line() check from current coordinates to where it will end up.

If it's tiles, run a for loop checking for a tile from start position to where it will end up.
 
T

TinyGamesLab

Guest
Thanks! I made it and it looks pretty good, but somewhy when player is close to the wall it spawns inside of the block, but I can accept it. Thanks again!
Where do you spawn your bullet object? You probably use the player x and y position + an offset. In this case have a collision check run on the creation event of the bullet and if it hits the wall, have it x position changed to a position closer to the player (maybe just in cases like this have its x position = player.x)
 
E

Edwin

Guest
Where do you spawn your bullet object? You probably use the player x and y position + an offset. In this case have a collision check run on the creation event of the bullet and if it hits the wall, have it x position changed to a position closer to the player (maybe just in cases like this have its x position = player.x)
I spawn it inside the player object (x, y, o_bullet). I fixed this problem with just making bullet's depth less than wall objects so it's not bothering me anymore. Thanks!
 
E

Edwin

Guest
You can always do a collision check before it moves, and the length it is going to move. For instance, if your wall is an object, do a collision_line() check from current coordinates to where it will end up.

If it's tiles, run a for loop checking for a tile from start position to where it will end up.
Thanks for your advises!
 
E

Edwin

Guest
If it spawns inside the wall perhaps that should also be another trigger to do the exact same thing in the create event? Might be tougher to pull that off though - to get 100% always perfect results you'd want to design your own custom collision system and well, that's not easy haha. Good luck!
Thanks!
 
Top