# How do I only score a basket when the ball goes in one way?

Get help using Construct 2

### » Thu May 14, 2015 10:08 pm

Hello everyone!

I've been playing around with a 2D basketball game. I have the physics and the gameplay down. My only problem is, when the ball even barely passes through the hoop, it counts it as a basket. For example, if the ball bounces off the ground and moves through the hoop from the bottom-up, it counts it. Like a reverse basket.
The way I have it set to score is, I have a thin line sprite that sits inside the hoop. When the ball passes through the line, it counts it as a basket. Is there a better way to do this?
B
4
S
1
Posts: 8
Reputation: 743

### » Thu May 14, 2015 10:29 pm

The Y axis increases downwards, so if the BALL's Y co-ordinate is lower than the basket, they are above it. BALL -> Compare Y -> Less than, Basket.Y add this to your collision event

EDITED player to ball for you it still works the same it was just so you could get how it works idk what these things are called in your personal project

Last edited by volkiller730 on Fri May 15, 2015 12:25 am, edited 3 times in total.
B
43
S
17
G
2
Posts: 850
Reputation: 6,234

### » Thu May 14, 2015 10:36 pm

Sorry, I should have specified. The game doesn't really have a "player". The ball is launched Angry Bird style at a basket. Sometimes when the ball bounces off the ground, it will pass through the hoop from the bottom. When it does that, the game counts it as a basket. I want it to only count if the ball passes completely through the hoop and only from top to bottom.
B
4
S
1
Posts: 8
Reputation: 743

### » Thu May 14, 2015 11:01 pm

I think what volKiller was saying is that you test the ball collision with the hoop and then compare the Y position of the ball to the hoop if the ball Y is less than the hoop then add a point. I think that is what he mean but I could be wrong but that is a way of doing it.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

### » Fri May 15, 2015 1:32 am

my first idea was to use bbox's but then i figure out that it will still do it, and you be over complicating yourself, what you could do is , add another thin line, under and when the basketball hits it push the basketball back, towards ground, if basketball hits the upper line disable collision on the bottom line, so it doesn't push it anymore, then wait 0.5 and enable collision back on,
B
82
S
24
G
69
Posts: 1,363
Reputation: 44,216

### » Fri May 15, 2015 3:35 am

I think I figured it out!
First, I added a thin line in the hoop.
When the ball passes over the line, it adds a value of 5 to my variable MakeBasket, which has a starting value of 0.
Right below that line, I have another thin line that adds another value of 5 to the variable.
I added a new event that looks for the MakeBasket variable to have a value of 10. If it does, then it registers a basket.

To keep it from adding a point when the ball travels in the opposite direction, I used gamecorpstudio's advice and made the bottom line a solid, until the ball is currently in contact with the top line.

Works like a charm! Thanks for all your help
B
4
S
1
Posts: 8
Reputation: 743

### Who is online

Users browsing this forum: No registered users and 11 guests