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

Better collisions

J

James7285

Guest
Hello,
I am making a launch game where you have to fly a rocket from earth to space.

The game is almost complete but there is one thing I'm having a bit of an issue with.

As you get higher and higher you encounter different obstacles (hot air balloons, plane, UFO's etc) and I have set it so that when the rocket collides with them you bounce off (Move_bounce_all). This is to hinder your progress and knock you down a bit.

I don't need the other objects to bounce on collision, just the rocket. The other objects do fly across the screen though.

Most of the time when I hit the objects I bounce off them exactly as I should, but sometimes if I hit them at a funny angle, or especially if they hit me side on as I'm trying to fly past, I end up getting stuck on them.

I can usually wiggle free or once they pass through me I can usually carry on.

Any ideas on how to get round this? Should I be using more advance collision code?

If it helps I'm not using precision masks or precision collision detection. (I have tried turning these on and it didn't help)

Thanks for your time.

James
 

lolslayer

Member
You can make it that way that you'll only slow down when you collide with another object, the other object could be destroyed after collision, this way you won't get stuck in it
 
J

James7285

Guest
Thanks for the reply.

If possible i'd rather keep the objects there as it's part of the gameplay having to get past them. Again, same thing with the bounce rather than a slow down is a way of punishing you and sending you back a bit.
 

csanyk

Member
First, use the simplest collision mask you can.

I can't imagine why the other object moves when you're hitting it, if the only code in the collision is to move_bounce_all the player's rocket.

As for getting stuck, you could try move_outside_all() to ensure the rocket is no longer in collision after the bounce happens.
 

Yal

🐧 *penguin noises*
GMC Elder
You could make the bouncy objects solid, it will automatically move them (and the player) out of the collision. It's not as reliable as coding it yourself, but it's a very easy change to make (and it won't make bounce_all stop working since "all objects" also includes all solid objects)
 
J

James7285

Guest
I have done it csanyk's way. It's not perfect as it moves you out the way rather than bouncing you, but it only happens rarely anyway so it will be fine this one.

Thanks for your help.
 

csanyk

Member
You could make the bouncy objects solid, it will automatically move them (and the player) out of the collision. It's not as reliable as coding it yourself, but it's a very easy change to make (and it won't make bounce_all stop working since "all objects" also includes all solid objects)
I haven't used the solid property in objects since GM8.1, after reading long ago that most GM programmers don't use it due to problems with moving objects getting stuck in solid objects. I did have problems on one of my earliest projects where this absolutely did happen -- a moving instance collided with a solid instance, and became stuck in it. There wasn't anything automatically moving it outside of collision so that it could move freely. I had to code it myself. Has something changed?
 

Yal

🐧 *penguin noises*
GMC Elder
Has something changed?
Not really, so I guess your thing getting stuck was due to the way you moved it. Collision events with a solid object involved moves back both objects to their pre-collision positions before the actual event runs, so in most basic cases they wouldn't overlap after a collision.
 

csanyk

Member
Not really, so I guess your thing getting stuck was due to the way you moved it. Collision events with a solid object involved moves back both objects to their pre-collision positions before the actual event runs, so in most basic cases they wouldn't overlap after a collision.
I was using speed and direction. What's the preferred way?
 

Yal

🐧 *penguin noises*
GMC Elder
Did you by chance use image_angle as well? That changes the collision mask, which can cause collisions without movement (and that breaks down the way solid objects act, since moving you back to where you were before won't eliminate the collision)
 

csanyk

Member
Did you by chance use image_angle as well? That changes the collision mask, which can cause collisions without movement (and that breaks down the way solid objects act, since moving you back to where you were before won't eliminate the collision)
Actually, yes, I was changing image_angle.
 
Top