I’ve been working on a world where the player needs to go around various spaces and eat everything in the space to move forward. The biggest challenge for me so far has been how to get a reference in code for the player’s head?  What I want is to add code to every edible object:

If edible object collides with player head object, edible object plays sound, plays particle FX, hides, and sends an event to an Uber game object that is keeping track of scoring.

I can’t figure out how to get a reference to the player head, so for now I’ve created a wearable / attachable mask that the player needs to put on. The mask contains a trigger that collides with objects tagged ‘eat’, and the edible objects also have a script that reacts to collision with objects with the ‘head’ tag, which the trigger has.

<insert screen cap of edible code>

<insert screen cap of head code>

<insert gif of eating in Horizon>

I’m happy with the way this works, and the mask adds to this particular game experience, but I don’t want to have to force masks for every situation.

I found a different kind of weird workaround, where if I make the edible object attachable to the head like a hat, it will trigger the onAttach event and I can play code that way. I don’t know if that will work for multiple edible objects, though, and seems pretty clunky.

I’m going to keep looking and will update this post when I find more.