Int not updating after player completes task

So, I’m building a simple puzzle in VR using the XR Interaction Toolkit. In order to complete the puzzle, the player needs to insert pieces into the correct sockets. The script tracks the number of correct pieces and the puzzle should be complete when the player inserts two pieces correctly. I have the script below. I have tried this over and over again, but the number of complete tasks does not update.

Here is the script on the individual sockets. The two should talk to each other. I feel like I must have made a simple mistake, but I can’t find it and it is driving me nuts.

EDIT: Disregard, I mixed something up.

So, something like this?

8420292--1113954--upload_2022-9-6_16-13-57.png

Thank you. I will give it a try.

Not sure if I had it right, but this did not fix the issue.

For C# strings the == operator is overloaded to compare the values, not the references.

My bad, mixed up my C# and Java. I’ll edit my post to avoid confusion, sorry about that.

The only other piece of advice I can give is to generously sprinkle Debug.Log(); calls into the code to see where exactly things don’t work as expected. To me the code doesn’t have any obvious mistakes, so I’d guess CompletedPuzzleTask isn’t called, maybe because the surrounding if-clause never evaluates to true or the ObjectSnapped callback is never called.

Ok, thank you both. I suspect that the CompletedPuzzleTask isn’t being called as well. Just need to figure out where the breakdown occurs.

Use Debug.Log to find out for sure, as was mentioned. https://discussions.unity.com/t/748729/14