In need of some advise

0 favourites
  • 5 posts
  • Hi,

    I am looking for some advise for a game I'm making.

    There is a ball and some chests placed around. When the ball collides with the chest it opens and reveals a prize. The issue I'm having is that it happens that the ball collides with 2 or 3 chests at the same time, and when that happens it only adds one prize, not all of them.

    The prizes depends on which frame the object had when the ball collided with it. So for example frame 0 - 9 has no prize, while 10 does. So I'm basically checking "Animation frame = 10, then add to prize".

    I'm using one object that I copied around for all the chests, I tried using a different object for all of them but the game takes up so much space when I do that. It added 15MB just for that. The thought was that then it would add all the prizes correctly, since then I do a check on each individual chest instead of only on one. But when there is 77 chests, it would be a lot of work if I need to add more frames or do some changes, I have to do that on all of them. So I guess that when 2 chests opens at the same time, the program thinks it's 1.

    Any ideas of what I can do here? Thanks.

    Regards,

    Edgar

  • Even if you collided with multiple chests at the same time it would still run logic for all of them I would imagine if you had an event on collision with chest. You can check that by adding some logging.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Even if you collided with multiple chests at the same time it would still run logic for all of them I would imagine if you had an event on collision with chest. You can check that by adding some logging.

    Thanks for the reply lionz,

    I have added a variable called "collide", and every time the ball hits the chest it adds one to it, but it adds only one when the ball collides with 2 or 3 chests at the same time. Can it be that it only checks for that one event since it's happening simultaneously, since it's the same object and all 3 chests have frame 10, but they are the same copied instance of each other?

    What I'm thinking is that I have to either make the ball smaller or the chests bigger, so that the ball can't collide with more than one chest at the time. But that would require changing of design and positioning of the objects etc...

    If you have any other ideas I would appreciate it a lot!

    Thanks.

    Regards,

    Edgar

  • I don't see why that would be the reason. You are talking about adding to a global variable? If you placed all chests on top of each other and the ball collided it would still add 1 to the variable for all chests hit.

  • you might need a "For each chest" to process each one the ball collided with. Although a collision is normally triggered for each instance as far as I know.

    you could log the Chest.PickedCount to see if it is trying to process several at one time.

    What you are describing should work - without having to redesign things. If it isn't doing what you want, then create a small sample file for us to look at.

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