How do I prevent wrong totals adding to score variable?

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I'm creating a test of a game whereby the user must hold down a button which will shoot a ball and they must hold the button for the right amount of time so they get the ball to land on the target. The scores are as follows:

    Green circle - 2 points

    Yellow circle - 5 points

    Red circle - 10 points

    What I'm currently doing in the events is comparing which object the ball is overlapping to determine how many points are added to the score variable. However, when the ball is over the red circle for instance, it's adding 17 to score as it's also overlapping the other two circles.

    Is there a way to get around this?

  • Create some kind of loop that checks if overlapping red and if so then add and stop the loop, else check yellow, then green.

  • What should I use as the start and end indexes?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't use overlaps or collisions. use distance from the center. You only have to figure out how far from the center each circle is. so when ball hits target calculate distance from the center of the target. Then if less than 100, that means 10 points because it's in the red, if over 100 but less than 150 then it is in the yellow and so on.

    My numbers are obviously just examples, you have to change them to your numbers/target dimensions

  • If you want to use overlapping, make sure to add a "pick top instance" condition. Howevever, BadMarios suggestion is more accurate, since it doesn't have to rely on collision polygons.

  • Cheers for your help guys - I've managed to get it working right by using distance from the centre. Really appreciate it!

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