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

0 favourites
• 6 posts
From the Asset Store
The ultimate voice pack filled with 1,536 files of .......wav and mp3 of individual numbers, letters, and words (that go
• 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?

• 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

• ## Try Construct 3

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

Construct 3 users don't see these ads
• 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.

• 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.

• 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,

• 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

• 6 posts