How to make score count only when ball enters from the top of the ring

wongj19wongj19 Member Posts: 45

Sorry for bothering you guys again but it seems that I have hit yet another problem when making my game.
My game I plan to make is a front on basketball shooter. The problem is that the ball crosses the ring twice, once on the way toward the ring and once on the way down. I was wondering how to make the ball only be able to enter on the way down.
As always any suggestions are greatly appreciated. :smiley:

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2016

    @wongj19 said:
    I was wondering how to make the ball only be able to enter on the way down.

    Have a duplicate ring actor in front of the ball - with its alpha value set to 0 (so it's invisible) - when the ball reaches a certain Y position change this alpha value to 1.

  • wongj19wongj19 Member Posts: 45

    @Socks said:
    Have a duplicate ring actor in front of the ball - with its alpha value set to 0 (so it's invisible) - when the ball reaches a certain Y position change this alpha value to 1.

    Sorry maybe I was a little unclear. I meant making the points actually count that goes to a scoreboard and not to create the effect that the ball was going in. At the moment I have an actor at in the middle of the ring but the problem is that the ball crosses it twice, once on the way up and once on the way down. I want to find out how to make it only trigger the actor when the ball is on the way down. Thanks

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited June 2016

    This is what you want

    With this you can add a rule to say that if it's going down and collides with your hoop increase the score.

  • wongj19wongj19 Member Posts: 45

    @KevinCross said:
    This is what you want

    With this you can add a rule to say that if it's going down and collides with your hoop increase the score.

    Thanks sooo much. I tried it and it was going well until I added the rule:
    When- ball.linearvelocityY < 0

    • ball collides with goal detector
    • flick is true

    then: Change attribute game.score to game.score +1

    I've attached my game onto this post if u could check to see where I went wrong, that would be amazing.

    https://encodable.com/cgi-bin/filechucker.cgi?action=landing&path=/&file=basketball_flick_staight_on_version.gameproj.zip

  • wongj19wongj19 Member Posts: 45

    ^ @KevinCross pls help

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    @wongj19 said:
    ^ @KevinCross pls help

    I don't have an active license with GameSalad so can't open your project

  • wongj19wongj19 Member Posts: 45

    If I took a screenshot of my code would u be able to figure it out? @KevinCross

  • ArmellineArmelline Member, PRO Posts: 5,332

    You'll need to do some work on the balls, particularly limiting them to 1 active at a time, but this is one way to do what you want. If you need multiple balls active at the same time, it'll get a little more complicated.

  • wongj19wongj19 Member Posts: 45

    @Armelline said:
    You'll need to do some work on the balls, particularly limiting them to 1 active at a time, but this is one way to do what you want. If you need multiple balls active at the same time, it'll get a little more complicated.

    How can I limit it to one active ball at a time? Is that why my game isn't keeping score? Thanks :smile:

  • ArmellineArmelline Member, PRO Posts: 5,332

    Your game wasn't keeping score for a lot of reasons. The file I attached shows you how to make it keep score. And have the ball go in front of/behind the net properly. Did you look at it?

  • wongj19wongj19 Member Posts: 45

    @Armelline said:
    And have the ball go in front of/behind the net properly. Did you look at it?

    Yea... Can't figure it out. Any suggestions?

  • wongj19wongj19 Member Posts: 45

    ^ oh wait never mind. its in the file you sent. Thanks

  • wongj19wongj19 Member Posts: 45

    @Armelline could u please explain a few things from your file that u sent me?

    Image and video hosting by TinyPic

    and

    Image and video hosting by TinyPic

    Thanks!

  • ArmellineArmelline Member, PRO Posts: 5,332
    edited July 2016

    The first screen shot is of something you did, not me, so I'm afraid I can't tell you. I'm guessing one of the unnecessary actors I deleted was being used there.

    The second is the bottom net working out when the ball position is higher than the position of the basket + half the height of the basket + half the height of the ball (so when the bottom of the ball is higher than the top of the basket). When the ball is higher than the basket, we spawn another copy of the basket for the ball to go underneath, to give the illusion that the ball has passed first in front of the rim, then behind the rim (as it goes into the basket).

  • wongj19wongj19 Member Posts: 45

    thanks @Armelline

    @Armelline said:
    When the ball is higher than the basket, we spawn another copy of the basket for the ball to go underneath, to give the illusion that the ball has passed first in front of the rim, then behind the rim (as it goes into the basket).

    ^ genius :smiley:

    another thing is that I tried to make it so that the ball would get destroyed when colliding with the basket on the way down, I made up this small bit of code (in the ball actor) but it does't seem to work. :neutral:

    Image and video hosting by TinyPic

  • ArmellineArmelline Member, PRO Posts: 5,332

    What happens? I'd need to see more to tell you why it isn't working. But do you really want to destroy the balls as soon as they touch the basket on the way down? That would seem to kill the feeling of getting a basket.

Sign In or Register to comment.