PINBALL QUEST: ‘10X’ - Solutions

Quest: Pinball
Challenge: 10X

Feel free to share your solutions, ideas and creations below. If you get stuck, you can find some ideas here for completing this challenge.

@EddieRocks
To Mr. Rocks or whoever can please assist. I’m almost done pinball quest (I had help). But there are issues I don’t even know where to begin looking for answers to. My issue is my pinball gate only sometimes works when colliding with the pinball.

{
PolygonCollider2D _thisCollider;

private void Start()
{
    _thisCollider = GetComponent<PolygonCollider2D>();
    
}
private void OnTriggerEnter2D(Collider2D other)
{
    if (other.tag == "ball" && _thisCollider.isTrigger)
    {
        StartCoroutine(ChangingTriggerAfterBallCollision());
    }
}

private IEnumerator ChangingTriggerAfterBallCollision()
{
    yield return new WaitForSeconds(0.1f);
    _thisCollider.isTrigger = false;
}

public void ToggleIsTrigger(bool isTrigger)
{
    this.GetComponent<PolygonCollider2D>().isTrigger = isTrigger;
}

}

That code will work sometimes & sometimes it ignores the ball & I can’t simply use the plunger to get the ball moving until I lose that ball & things auto-reset.

Sorry not sure what you are doing as you’ve put it under the x10 challenge.

Is this part of “Launch it” ?

While you’re at it, implement a way to stop the ball from rolling back down to the bottom of the launch area.

If so can you raise the question there or under whichever Challenge it is and I’ll answer it more fully there.

Hint: If it is the problem then colliders are sometimes not triggered if the ball is too fast so I had to use 2 colliders one to stop the ball going back and a larger trigger higher up to know the ball had passed and flicked them on or off as necessary.

Thanks Mr. Rocks.
I don’t know what this falls under but if you say it falls under “Launch it” then I can propose that question there. When I looked at the list there was nothing called “Ball Stopper” so I just asked in general.
I tried doing that with the ball stopper but maybe I can do that with the ball.

May be i dont understand what you are trying to do.
Is it stopping the ball falling back to the launch pin after its been fired?
I don’t know what gate you mean

Hey again,

Try doing a couple of things. First. On The Almighty Ball → RigidBody2D → Collision Detection Set it to Continuous. It uses more resources but from my understanding, it’s supposed to do physics checks more aggressively.

Now for your Ball Stopper issue. I’ll give you a push in the right direction: Platform Effector 2D. Take a look (there’s a great youtube video) and if you get stuck, hit me up.

That’d be easier than the way i did it!

First I tried hinge joints. Not ending well is an understatement.

It doesn’t look quite right, but it works.

Thank you I’ll look into that effector now. So I added more colliders to the ball & now it duplicates itself for whatever reason. The ball still will sometimes pass through the Ball Stopper.

On the ball, there’s a setting called continuous. I think it’s on the Rigidbody, but it could be on the collider. Set that and you’re usually sorted.

If that doesn’t work, there used to be a physics setting, but last time I went searching for it, I couldn’t find it. Another trick was to reduce the time between physics ticks. It soaks up way more resources, but it can help with that issue.

Another way is to set up raycasting with the ball, but that’s a very unfun solution.

Another way is to get the ball to move slower. It’s less fun but it lets the physics engine keep up.

I’ll try those things. I really don’t think I’m going to have “Pinball Quest” working for some time as it seems a lot harder then Rick makes it look. I have no idea why my balls are replicating so I been trying to solve that issue. I’m not really keen on slowing the ball down because it takes away some of the fun but that can be a last result. I’ll have to learn what raycasting is I never heard of it. The continuous thing doesn’t seem to make a difference. I also tried putting 2 colliders on either the ball or the stopper. Both yielded adverse results & more problems.
Also
@MichaelP Thank you for what you said I appreciate that.

Oh yeah, don’t put extra colliders on unless you need to design it that way. Unless you need some sort of zoning, it rarely works out well.

I’d guess it’d be from going against the single responsibility principle (and putting that on the right object). It’s probably a lot of gobbly gook to you right now.

But I’d guess (wild guess mind you, no reason beyond fairy magic behind it) you’re putting the code to spawn the ball in the code that’s on the ball and you’re having some logic issues with it.

It was the quest that gave me the most issues. I’m happier in code than in the inspector and I found this one was mostly solved in the inspector.