Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hello again Peter
I noticed that in this engine o_enemy_parent checks for collision with the player and run "process_enemy_attack()" while in the Udemy course Castle Raider it's the opposite, player checks for a collision with the enemy. I googled to see what is better and usually answer is that it's better if player checks for the collision.

I wonder what would you recommend?

(2 edits)

Hey Joe,

That's a good observation actually.

To be fair it should be slightly (and I say ever so slightly) faster to have the player check for the collision against all of the enemies as one instance checks for a collision with multiple instances, so the internal code for that to run is only referenced once, even though the collision check is still done against every enemy, while the alternate method is each enemy checks for a single collision with the player instance, so may have slightly more overhead, but in the end the same amount of collision checks occur, just the small overhead to set up each check is only run once with the player to enemy collision check.

I'd have to actually do a benchmark though and see what the results are before confirming how much time we are saving.

I remember setting it like that in the Castle Raider course to essentially teach what I believe should be faster, and I may of swapped it in this engine to test it out, and didn't notice any difference so just left it.  To be honest I don't actually recall why I never swapped it back.

Thank you very much for your answer. Looks like it doesn't make much difference but I will keep it in the player as is more simple that way and perhaps runs a bit faster.