Recommended approach for hazard as part of a tile?

Hello! I absolutely loved this course, and now I’m working on my own (very simple) game.

Let’s say you have a tile with spikes on the left and right, so that it’s a hazard to touch the spikes, but you can still jump onto the top. But then you have another tile with spikes on the top and bottom, but not the sides, for example.

Is there a recommended approach for defining parts of a tile as a hazard, instead of an all-or-none-approach like we did here with the spikes and water?

Thanks :slight_smile:

Hi Ryan,

That’s possible and relatively simple. First of all, you do not have to put everything onto one game object. You can use children. For example, the “dangeous” part of your spikes game object could be on the child with a separate collider and a hazard script. Secondly, you could use a tag for the child and check for certain tags whenever a collision happens.

For more ideas, please feel free to ask our helpful community of students for advice in our official Discord chat.

Hopefully, this helped. :slight_smile:

Thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms