Forum rules - please read before posting.

Creating Hotspots through Script

edited April 2022 in Technical Q&A

I am trying to create a hotspot through script.
But it seems inactive.

This is my code:
`c

hotspot = GetComponent<Hotspot>();

    proxyHotspot = (new GameObject("proxy_"+this.gameObject.name)).AddComponent<Hotspot>();
    proxyHotspot.transform.position = new Vector3(1000, 1000, 1000);
    proxyHotspot.transform.parent = this.transform.parent;

    proxyHotspot.walkToMarker = hotspot.walkToMarker;

    proxyHotspot.useButton = new Button();
    proxyHotspot.useButton.faceAfter = true;
    proxyHotspot.useButton.playerAction = PlayerAction.WalkToMarker;
    proxyHotspot.useButton.interaction = interaction;
    proxyHotspot.useButton.isDisabled = false;

    proxyHotspot.provideUseInteraction = true;
    proxyHotspot.provideLookInteraction = false;
    proxyHotspot.provideUnhandledUseInteraction = false;`

When I select it in the editor during gameplay I receive: Hotspot 'proxy_Door' has been temporarily upgraded - please view its Inspector when the game ends and save the scene.

And after that the hotspot works as expected.
What am I doing wrong?

Comments

  • edited April 2022

    Oh sorry, I realized that I can just call proxyHotspot.UpgradeSelf(); myself or that I have to add proxyHotspot.AddUseButtons(useButton)

  • useButton is deprecated in favour of the useButtons List. Try this instead:

    Button useButton = new Button();
    useButton.faceAfter = true;
    useButton.playerAction = PlayerAction.WalkToMarker;
    useButton.interaction = interaction;
    useButton.isDisabled = false;
    useButtons.Add (useButton);
    
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.