Advertisement

How to do a collision check only once, game maker studio (GML)

Started by November 22, 2018 03:06 PM
19 comments, last by akshayMore 6 years ago
2 minutes ago, CyberFlash said:

Wait Game Maker has something called 'id' that should give me the values already? I just need to compare them somehow perhaps?

Likely so, check the docs.

Usually all objects are stored in an array of constant or variable size, then you could use the index to the array.

But this can cause problems if an object in the middle gets deleted, so the usual solution is an id given at creation which remains constant for the lifetime of the object.

You need to know those things, but using engines like GameMaker you have to read them up and learn some internals. A bit of a downside when using such frameworks.

We have liftoff!!! 

i've gone with 


if (other.lastHit != id)
{
    currentHp = currentHp - pain;
    other.lastHit = id;
}

and placed this inside my enemy, on the basis that it collides with a bullet object. I've got other things in here checking which sprite is active to determine the damage it takes based on the type of bullet kinda thing so I just switched it a tiny bit like


bullet.lastHit = npc.id;

'other' is automatically meaning the thing that it collides with (which is only going to be a bullet as that is set), and i took away npc. because id already belongs to this enemy getting hit...  And it works across them all! 

-- Basically I couldn't get a flamethrower to work so decided to go for a 'fire ball' type bullet that'll go through enemies... and it was so OP because it hits multiple times! Thanks once again to ye awesome forum folks for helping :)

Check out my game '3NDL3ZZ: Base Defense' A simple militant styled, tower defense game.

GameDev.Net Project Page

Advertisement

Glad everything is working now!

@JoeJ MVP. :) 

Programmer and 3D Artist

15 minutes ago, JoeJ said:

You need to know those things,

I'm finding this more and more when I post on here and people just know things and say things and I'm like "Hmmm yeah that sounds vaguely reasonable" and then i google again with specific things folks say to find how its used. It makes me think I should study/use something else than Game Maker sometimes but it "Does the job" for now so I'm happy lol

Check out my game '3NDL3ZZ: Base Defense' A simple militant styled, tower defense game.

GameDev.Net Project Page

2 minutes ago, CyberFlash said:

It makes me think I should study/use something else than Game Maker sometimes

Yes if you are seriously interested in programming, and no if you are interested mainly in game design, i would say.

But even in the latter case you should look at Unity / UE4 etc. at some time...

 

Personally i'm the opposite - still no experience with any of those engines, and this does not feel any better! :D

 

 

 

@CyberFlash man... You should've seen my struggles when I went from being someone that has programmed tool-kits and engines prior to even using 3rd party stuff... It was extremely hard to adjust. I was making a lot of tool-kits for my projects mid 2000's and working on an engine which I loved doing. I just recently tried out Unity for the Frogger challenge, and wow... even though stuff is easier on one side, I struggle because I cannot do certain things the way I want under the surface, ect... I see things differently... Old habits, Loss of control, ect... On that note, I used GameMaker back when Mark Overmars ran the show way back in 2000, and even then I couldn't stick it out long enough and went back to using my own stuff. I ran into too many moments where I would tell myself "If I could only change (x) feature...".

You have benefits on both fronts, using other tools and making your own. It all depends on what you truly want, and back then I was more interested in making the stuff that is used for games, not so much the games themselves. :D 

Good ole' memory lane!

Programmer and 3D Artist

Advertisement

Aha I see, 

31 minutes ago, JoeJ said:

still no experience with any of those engines

 

24 minutes ago, Rutin said:

I cannot do certain things the way I want under the surface

I've basically only ever started with prebuilt engine stuff so I don't know what I'm missing out on. I mean I originally started with Construct 2 and then went to Unity and both were cool to use but I was going through the not finishing phase :P And then I bought Humble Bundle with Game Maker a fair while ago and I've just been using that. 

I think to get a real taste of the title 'developer' I gotta learn what its like without an engine already built but where would one start ? to the Youtubes! It shall be fun! :D 

26 minutes ago, Rutin said:

If I could only change (x) feature

I used to see a lot 'drag n drop' methods for Game Maker but I've never learnt to use that stuff, I imagine that is what it was like back in those early days? Or did they always have a code option? I like to use the code option because I feel like I can control everything that happens assuming I know how to/someone on this forum knows :P I couldn't even begin to imagine having allll the control over every feature ever though ?

Check out my game '3NDL3ZZ: Base Defense' A simple militant styled, tower defense game.

GameDev.Net Project Page

19 minutes ago, CyberFlash said:

I used to see a lot 'drag n drop' methods for Game Maker but I've never learnt to use that stuff, I imagine that is what it was like back in those early days? Or did they always have a code option? I like to use the code option because I feel like I can control everything that happens assuming I know how to/someone on this forum knows :P I couldn't even begin to imagine having allll the control over every feature ever though ?

It's been awhile since that time but I believe in 1999 or was it 2000 when I first used it (more of a trying out thing, I used it more so in version 4 when playing around), Drag and Drop was in there and what I used most of the time, and I believe scripting was there as well. If I remember correctly, I put in a script back in the day that would have enemies follow the player... :D I even had a friend who made .dll extensions to game maker to add in some very primitive 3D stuff, and model loading, which was cool at the time. Not sure exactly how it was done, but the forums were blazing at that time when you could have a 3D room in Game Maker. :D I toyed around with it again with version 4, but again... wasn't my cup of tea. With my established code base I could still throw together 2D games in a quick rate using my custom tools and engine. Getting to that point was a long journey because the amount of time I spent experimenting, but I've benefited greatly from that experience today.

Heck, I even used DarkBASIC for a bit... but at the end of the day I always reverted to C++, and later on C# for tool-kits. C++ is still my most used language to date. :) 

It never hurts to experiment!

 

Programmer and 3D Artist

56 minutes ago, CyberFlash said:

I couldn't even begin to imagine having allll the control over every feature ever though

On the other hand, a question like in this topic would never come up. You would know how stuff is stored in memory, you would know how each object is made and works, you would know how to differentiate between each, you would know how to solve the bullet problem already before it comes up at all.

Downside is you would make less games and more tech in the same time i guess.

1. "Bullets that get destroyed on collision with enemies "

In this case multiple collision is not an issue as the object(bullet) is no longer there. If you think from bullet's perspective....its weakness is enemy collision.

2."Bullets that are not destroyed on collision."

If you think from bullet's perspective......its weakness is no longer enemy collision but its own lifespan( timer).

From enemy's perspective.....to handle multiple collision with the bullet.

  • I would make enemy immune for few seconds(or ms) ( where it ignores collision from the passing bullet). After the time have elapsed, the enemy is ready for fresh collision. You don't have to keep a track of IDs and checks in this case. 
  • Other way would be to handle this using ID/Boolean checks as mentioned by others. 

This topic is closed to new replies.

Advertisement