Collision calculations

Game Editor comments and discussion.

Collision calculations

Postby lverona » Fri Jan 25, 2013 6:24 am

Say, I have a bullet and several targets. Is there any performance related difference between these two variations?

a. Put all collision events into a bullet.
b. Put one collision event with bullet into every target.
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Collision calculations

Postby skydereign » Fri Jan 25, 2013 7:15 am

I usually recommend putting it in the actor with the least number of instances, but that is just for organization purposes. If you test it, gE's collision system is smart enough, that there is no noticeable efficiency difference. I find picking a convention just makes it easier to work in gE. There is though another factor to consider. Putting it in the enemy may actually make your code easier and cleaner. Namely, if you need to reference the enemy actor's parent, or creator actor (which is more common that needing to know the bullet's parent or creator) you would want the collision event to belong to the enemy. That way you can utilize the parent/creator especial actor types.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision calculations

Postby lverona » Fri Jan 25, 2013 7:23 am

Okay, great, I did go for variant b.

I generate enemies right before view and destroy as they exit the view, so I think it should be ok performance-wise.

Is there any limit on collision events? Or if there are not many objects at the same time present in the game, then it is fine?
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Collision calculations

Postby skydereign » Fri Jan 25, 2013 7:30 am

Collision events are reported to slow down the game. But usually that only occurs in games that have a lot of actors on the screen (and off the screen) at the same time. So I believe often the lag people experience is due to drawing images rather than the actual collisions. Though, colliding with large tiled actors does slow things down as well. As long as you clean up unnecessary actors, and your game isn't a ridiculous bullet hell type game, you should be fine.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision calculations

Postby lverona » Fri Jan 25, 2013 7:44 am

What about having lots of various events created in scripts? I mean, you know, is there a limit on how many various events you can add to the game?
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Collision calculations

Postby skydereign » Fri Jan 25, 2013 7:54 am

Again, that would only start to be a problem if you have reached the point where the game lags due to actors. Events will normally only cause lag if they have really large loops.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest