Forum rules - please read before posting.

Custom polygon collider not working as a hotspot?

So, here's the deal: I'm making a 2D game, and I wish to use a custom shaped polygon collider as a hotspot. I've read, that this ought to work, but when I do this sequence:

1) Create Hotspot on top of a item
2) Remove Box Collider from Inspector
3) Add Polygon Collider 2D in Inspector and shape it
4) Tick "Is trigger"

Nothing happens in Game, and I can't even get the Hotspot label when I hover over the hotspot. It seems like the game is not detecting my hotspot at all? The hotspot does look different than the regular ones because this doesn't have the yellow filter on top, only the borders.

The answer is probably really simple, but I just can't figure it out!

Comments

  • Polygon Collider 2D components should work just fine - the 2D Demo's Tree Hotspot uses a similar technique.

    To clarify, though: did you remove a Box Collider, or a Box Collider 2D? If it was the former, then your original Hotspot was a 3D variant, set up for a 3D scene. What components are on other Hotspots in your scene that work?

    If your game is in 2D (as set by the Settings Manager's Camera Perspective setting), then your Hotspot should be detectable provided that:

    1. It's on the Default layer at runtime
    2. There are no other 2D Colliders in the way - also on the Default layer - that may be blocking it

    I can only speak in general terms without knowing more details, however. If the answer isn't clear, please share more in the way of screenshots so that I can see your specific setup.

  • All the other hotspots are just Box Colliders, not 2Ds. I did some experimenting and removed the Polygon collider 2D and replaced it with a few other colliders. Box Collider and Capsule Collider both work fine as a hotspot, but not if I select Box Collider 2D or Capsule Collider 2D. Henceforth, the problem seems to be in that 2D, like you mentioned. For Polygon I can only find 2D option, so what should I do?

    Besides Transform, Box Collider and Hotspot script the other working hotspots have only Remember transform components.

    Here's a picture of the scene attached. The layer is the default one and there shouldn't be anything on the way. Unity version btw is 2019.4.16f.

    https://imgur.com/a/PvtcU1s

  • edited January 2021

    If the other Hotspots work with Box Colliders, and not Box Collider 2Ds, then your game is in 3D - at least so far as AC understands it to be.

    Unity has no direct 3D equivalent for the Polygon Collider 2D component, but the closest match would be a Mesh Collider, with a custom mesh of the intended shape.

    Depending on how much progress you've made, and the complexity of your game (i.e. no on-screen characters / pathfinding), I'd recommend switching over to 2D if it's not too late. This would have to involve changing your game's Camera Perspective setting, and then replacing the various components with 2D counterparts (Box Collider -> Box Collider 2D, etc).

  • Oh damn, I wonder how I managed to pull that off. Well, I guess it's good that this came up now and not later.

    Our game is first-person, so no path-finding, and we haven't used any camera movement. How would I go on changing the game into 2D?

  • Back up first, then change your game's Camera Perspective setting to 2D (in the Settings Manager).

    Next, you'll have to replace your physics components on logic objects (Hotspot / Trigger etc) with 2D counterparts - so Box Collider is replaced by Box Collider 2D etc.

  • As silly as it may sound, I just simply can't find any "Camera perspective" settings from the Settings manager. https://imgur.com/a/OXZMYNI

  • Ah. The issue is that you've set your "Movement method" to "First Person", which refers to First Person in the traditional 3D sense. In this case, the game must be in 3D, so the field is hidden.

    I apologise for the confusion.

    If your game is in 2D but has no on-screen character, set your Movement method instead to None - and the field will then be visible.

  • Thank you so much for your help Chris, I managed to update the Camera setting and change the Colliders to their 2D counterparts, and everything seems to work now fine, including the Polygon collider. Cheers!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.