Trigger Check Answers button to appear

So now that I have the show/hide button working, and I know how to trigger collisions, I need to make the button only show up when each of the slots has been filled.

A question for myself:

  • does each slot need to be filled with a like color?
    • I’m not going to do this for now. I want to see how kids interact with it, and if they start learning the patterns on there own without too many initial restrictions.

Implementation questions:

  • how do I make sure that the slot is actually being filled, rather than just having been collided with?
  • Do I have the collisions/fillings count to 15, and on 15, the button shows up?
    • This could be something where if there are 15 collisions simultaneously, then the check button appears
  • Or do I have something arranged more individually, box collider by box collider …
  •  Or, this might not exactly be about collisions, but about slots being filled

This is a super cute interaction, and might be useful for me to reread in the future:

A lot of stuff was recommending Physics.OverlapSphere , which does maybe what I want but with a sphere.

I looked in the rest of the Physics command, and found Physics.CheckBox

This might be it – gonna give it a shot.

Joao just suggested these too ideas:

  • there’s also OnTriggerExit (cool I didn’t know!!!), so I could tally on trigger enters and on trigger exits and when it hits 15, I know they’re done

Boolean – is something placed here?

  • Joao also pointed out – but what if a letter block overlaps two box colliders 🙁 Which will almost definitely happen, unless I really change how I’m doing this, and I don’t want to bc I don’t want it to be too rigid bc it’s like 6 year-olds using this

OHHHH – I only need a single box collider, over the entire frame where the answer slots are, and then all I need is for all of the letter blocks to be inside it. Doesn’t need to be 15, doesn’t need to be individualized, just once all of the letter blocks collide or overlap with it simultaneously, then the check box appears. Really cool how that idea occurred to me while talking with Joao! Social thinking about coding problems is helpful and happy.

Hmmm … blocks are getting stuck in the box collider.

Keeping Track of Targets in a Trigger

Do I want a script on the collider block, or a script on each of the letter blocks? (Or … no matter where the script is, what direction is it going in – for every letter block, is it in the collider currently? )

blocks are getting stuck in the box collider:

PROBLEM: Because raycast from Move Object and Play Sound was hitting the box collider instead.
SOLUTION : move box collider to -1000, and then it works again.
This could also be potentially solved by using Raycast All, which might end up being necessary if there’s no way to satisfy all the z requirements.

So I’ve gotten it down to the point that being left in the boxcollider is making the letter blocks freeze and not be consistent about playing their own sounds. This happens even when I remove my collision script. I’ve removed the sprite component, rigidbody2D, and checked and unchecked “istrigger”. Hoping that the site below helps. This feels oddly familiar and maybe like something I’ve solved in the past, possibly in PuzzleBot.

When you raycast, it figures out all the things that are intersecting it. So it finds the first object (box collider) instead of finding the letters block (which it needs to in order for Move Object and Play Sound).

Raycast – can always deal with z things by just looking at all of the things. Raycast can give a bunch of different objects. –> there’s a Raycast All, which gives you a bunch of Raycast hits, which I can try to use at some point if my z stuff gets sad.

#todo – so keep an eye on if it ever happens that the order z needs to be in for every different thing isn’t possible.



make it so blocks don’t overlap so weirdly: 

PROBLEM: blocks overlap weirdly bc they’re all at the same z level, which means that the text overlaps with one of the colors behind it. It looks strange and isn’t useful.
SOLUTION: Make onsets a different z level (10) than middles (20), which should be a different z level than codas (30).


Render Check/Hide button when all 15 are in the box collider

For this one, I can use the same render script I used for the answer text inside the Check/Hide button itself.

Okay, so now I need to access the Check/Hide button from the collider.  OR I could put the collider script on the Check/Hide button.

Okay I need the collider script on the collider bc of this:

    void OnTriggerEnter2D(Collider2D other)

So instead I’m going to use this:

Noooo this is still for gameobjects, not for buttons.

Huh – why is the child of the button not getting enabled? I’ll just hack it and enable it specifically in the code.


Leave a Reply

Your email address will not be published. Required fields are marked *