Forum rules - please read before posting.

Hotspot detector

Hello Community,

I'm having a small issue with hotspot detector.. in my current scene, I do not wish to place the hotspot detector as a child of the player. instead, I want to assign the detector at the start of the scene when the player is spawned.

Is that achievable?

Comments

  • edited May 2021

    The Player's Hotspot detector can be assigned through script:

    AC.KickStarter.player.hotspotDetector = myHotpotDetector;
    
  • using UnityEngine;
    using AC;
    
    
    public class AssigHotspotDetector : MonoBehaviour
    {
    
    
    
        // Start is called before the first frame update
         void Start()
        {
            AC.KickStarter.player.hotspotDetector = myHotpotDetector;
        }
    
    
    }
    

    I tried something like this.. I got on error saying "does not exist in the current context"

    How can I get it to pick the detector on start? Do I have to name it myHotpotDetector?

    I would be grateful if you could help me fix this o:)

  • edited May 2021

    You need to declare "myHotspotDetector" as a DetectHotspots variable:

    public DetectHotspots myHotspotDetector;
    

    Place this above the Start function, and it will then be exposed as a field you can assign in your Inspector.

    Do be aware, though, that you don't need to spawn your Player into the scene - if you place the Player prefab in the scene file itself, AC will use this local instance instead, and you can assign the local Hotspot Detector to them as well. This may be easier than relying on a script to update the spawned Player instance.

  • Place this above the Start function, and it will then be exposed as a field you can assign in your Inspector.

    You are a life savior, I appreciate it!

    Do be aware, though, that you don't need to spawn your Player into the scene - if you place the Player prefab in the scene file itself, AC will use this local instance instead, and you can assign the local Hotspot Detector to them as well. This may be easier than relying on a script to update the spawned Player instance.

    Yes, I was aiming for this, but I since I'm using "player switching," I don't believe it would work..

  • Yes, I was aiming for this, but I since I'm using "player switching," I don't believe it would work..

    That's correct, in that case. Player-switching requires AC to handle all player-placement duties.

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.