Search Instagram Twitter Facebook Spotify Grid Tag Date Folder Chat Pencil

Cube Switch Activator Bug

Solved another bug tonight, but in the “not really” kind of way that makes me very uncomfortable.

Here’s the issue:

manifold_garden_cubeSwitchingBug

When you pick the cube from the tree, the one that is out on the switch (which is connected to the one on the tree) is reset and you can see it shrink away and disappear. However, the switch stays active and the door remains is open.

This needs to be addressed because this is not how the switch activators work, and the player ends up with an extra block.

After a bit of digging around, it turns out that OnTriggerEnter() is getting called twice:

OnTriggerEnter

I couldn’t figure out why this is. I think it has something to do with the cube changing layers when it goes from being held by the player to being on its own? I will have to look into this tomorrow.

The switch keeps track of the number of cubes in it in a list: _currentTriggeringCubes

Because OnTriggerEnter() is being called twice, the gravity cube is getting added twice to _currentTriggeringCubes.

When you go to remove the cube, it only deducts a count of 1, and so the switch thinks there’s still one cube left in it when in fact there are non.

I added this code to check to see if the cube is already inside the list before adding it:

manifold_garden_code

This check is good to have anyway, but it really bothers me that I can’t figure out why the OnTriggerEnter() method is getting called twice. Inevitably this bug will come up somewhere else later and end up causing other problems. I will ask David about it in the morning.

Anyway, here’s the switch working correctly: manifold_garden_cubeSwitchCorrect

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.