GameMaker Collision Event vs Instance_place

So i've been wondering now for a while. What exactly is the speed difference between the 2?

The reason i'm asking is because i've run into a problem with instance_place, where it only returns the id of one of the attacking parents. I have 2 objects a bullet and melee hit, which act under the AtkPar parent. I realized now i should've used instance_place_list to gather the list of attacking objects, because if 2 AtkPar objects attack at the same time only one of the Id's would be returned.

The issue is though that you would have to create a new ds_list every single time the attacking object collides with the enemy.

I originally wanted to make one list for each enemy upon creation but, every-time an enemy spawns it would have to create a new ds_list as well. Now i'm not entirely sure how many lists you can make before the game slows down dramatically, but wouldn't it be more efficient to use a collision event instead?

I'm not sure of the inner workings of how the collision event works but the collision event takes all ID's indiscriminately and leaves a smaller footprint in terms of not having to create a local list and then destroying it at the end. I could be overthinking things. But i wanted to know my options beforehand, before taking the extra steps of converting it to instance_place_list.

But what exactly are the benefits of using instance_place_list vs collision event?
 

HayManMarc

Member
This may not work for your issue, but could you put the effects of the collision in the bullet instead of the enemy? You wouldn't even need the ds list, then, correct?
 

TheouAegis

Member
Why would you need a list for every enemy? You're only going to be using the list for one block of code, so just share that one list between all instances. Lists are global in scope, after all.

You don't need to destroy the list either, just leave it sitting in the memory indefinitely. Clear it, run instance_place_list(), read it, then leave it.

The advantage of instance_place_list() is all your code is in one place.
 
Why would you need a list for every enemy? You're only going to be using the list for one block of code, so just share that one list between all instances. Lists are global in scope, after all.

You don't need to destroy the list either, just leave it sitting in the memory indefinitely. Clear it, run instance_place_list(), read it, then leave it.

The advantage of instance_place_list() is all your code is in one place.
Right that makes sense, but wouldn't the same be said for collision event as well , In my case it's very much so since the Shots and Melee attacks share a common parent. All i need are 3 variables to store the Id's that way it doesn't activate the Hurt patterns again, and since only 1 melee spawns and virtually all the bullets and such are destroyed upon hits anyways, it skips the need for instance_place_list and another ds_list entirely. I'm only wondering because if collision event is slower then i can understand and i'll change the workflow, but if they are virtually the same and the collision event is faster then i'd just settle for using that.

Also creating one list for all enemies seems like it wouldn't work out no? because upon hit all Id's are stored to this list and since all of the enemies share this list, that means when an attack hits another enemy at the same exact time, it would return that it's already been touched by this attack and might not even activate the hurt patterns.
 
Top