Simple question about performance and optimization

0 favourites
  • 3 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • I wasn't sure about what section to put this question in, so i'll put it in here, sorry if i'm wrong:

    this is more of just a general game dev question that has been bothering me.

    let's take this scenario:

    We have Sprite1 (player) and multiple instances of Sprite2 (scenery).

    when Sprite1 touches Sprite2 = perform action on Sprite2.

    That is simple, but i was thinking about the best, most optimized way to do this, regarding performance (in a situation where there is a lot of instances of Sprite2).

    i started thinking different ways to check this condition. for example, which is usually more efficient, distance check or collision check?

    say, if i disable all collision for Sprite2, and instead, use a distance check, like "distance between Sprite1 and Sprite2 is less than X = perform action on Sprite2". this is all assuming that the collision wouldn't need to be pixel perfect to begin with. and is there even more clever way to do this kind of check, for example to isolate and only check those instances (Sprite2) that are very close to the player (Sprite1)?

    i guess it's really apparent that i'm not a very experienced dev, so i apologise if this is a silly question. i just simply want to learn more about efficient ways to do things, and performance is something that is always on my mind. anyway, thanks for reading and for any possible tidbits of knowledge for this.

  • The current thinking is not to worry about performance at all--unless it becomes a problem. Program the simplest most brute force method first and then see if it is slow.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Answer your own performance questions with measurements. If I had to guess, I'd say using collisions/overlap would be faster, as the collision cells optimisation is an important way to improve efficiency (that's an old blog post, but the overall approach still applies in C3).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)