Forum rules - please read before posting.

Using GameObjects with hotspots

edited September 2018 in Technical Q&A
Hello,

In my game, inventory objects are things the player can fire out into the world as physical gameobjects. Like so!




The things the player fires out are just standard gameobjects:





What I need these to do is react with hotspots that are in the scene. When they collide with a hotspot they should trigger an action list (basically this is all akin to the player using an inventory object with a scene object).

What would be the best way of doing this? Configuring the hotspots to detect collisions with these inventory objects perhaps, or can anyone think of a better way?


Thanks,
T

Comments

  • I'm sure Chris can suggest the best way to do this, but I would probably experiment with using triggers instead of hotspots. Triggers will start an action list when a character collider touches it, I would guess that launching an object into a trigger should work out of the box without even needing a script too? Certainly worth experimenting with.
  • Aside from accessing the Hotspot component to actually trigger the interaction, I don't see a big need to involve AC with the collision aspect.

    Unity already provides methods to retrieve data about a collision:

    By using this in a script attached to your spawned objects - and detecting the presence of a Hotspot component on any object it collides with - you can determine if it's hit something you want to interact with, i.e.:

    void OnCollisionEnter(Collision collision)
    {
      Hotspot hitHotspot = collision.collider.GetComponent <Hotspot>();
      if (hitHotspot != null)
      {
        // Do stuff
      }
    }

    As for triggering the Hotspot interaction, see the Manual's "Custom interaction systems" chapter.
  • So I got a barebones solution working last night. Not sure if it's the most efficent way forward, but I like how it neatly keeps all the links to action lists on the hotspots.

    Step 1) Added a script to hotspots

    image

    2) The script itself has links to action lists and detects what the incoming thing was. If a particular thing hits, a particular action list can be started:

    image



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.