Forum rules - please read before posting.

Sending Hotspot to a Variable

Hi guys

I'm creating a first person adventure that uses context sensitive (lmb-use/rmb-examine)

To allow the player to see the object they're interacting with better I've decided to set up a two hotspot system

There is a larger hotspot square outside the object with the prefix "look"
another hotspot just bigger than the mesh nested inside the "look" hotspot (this will be the actual player interactions with the object)

When the player holds the mouse over the hotspots they're only able to interact with the "look" hotspot and upon clicking this the camera transitions to a zoomed in view of that particular object/interaction
This also sets the engine-manage system-change movement method to none to stop the player from being able to walk around while zoomed in.

The "look" hotspot is then disabled within the look hotspot ActionList so that the player is able to interact with the actual object hotspot that is nested within

I've set up an exitcloseup menu button for the player to click on that will return them to the normal view
eg if the player is interacting with a fusebox but doesn't have a fuse they will need to come back to this so can click the exitcloseup button to return to regular play.

I set this exitcloseup button up as a menu so it could be universal and wouldn't have to be done in the ActionList of every hotspot

The problem is that after clicking on the exitcloseup button the players view is returned but the "look" hotspot for that object that player was looking at eg "fusebox" is now disabled as it was disabled within the Use Actionlist as mentioned above

I'm trying to figure out a way to have that particular hotspot re-enable after clicking on closeexitmenu

I was thinking a variable might be the way to go
something like a isDisabled bool variable that gets sent the "look" hotspot the player has clicked on (or maybe an id for it?) that then holds that temporarily and upon clicking closeexitmenu it might set it to true or something which would re-enable that hotspot

but I'm not great with C# and a little unsure on if/how to go about sending a hotspot to a variable.

Any advice on how to implement this (or if I'm way overthinking this and there's a much simpler way to go about it) would be greatly appreciated

Thanks in advance

Comments

  • edited September 2021

    The "look" hotspot is then disabled within the look hotspot ActionList so that the player is able to interact with the actual object hotspot that is nested within

    This can be simplified if you keep your Player prefab inside the scene file, as you can then make use of the Hotspot component's "Limit to camera" field to have the outer Hotspot only be interactive with the First Person Camera, and the inner Hotspot only be interactive with its associated "close up" camera.

    This should avoid the need to use variables etc since your Close Up menu can then just return the Player to first-person.

    However for completeness / future reference, what you can also do is define a GameObject parameter in your "Exit Close Up" ActionList, and use this to override which Hotspot is turned on/off in your Hotspot: Enable or disable Action. You could then set this parameter value using ActionList: Set parameter at the moment the close up begins (i.e. in advance of the "exit" ActionList actually being run).

  • Thank you Chris, I've tried both methods and they work like a charm!!
    The "Limit To Camera" field is an especially cool feature I had no idea about.

    I think I would prefer to use the Limit To Camera method my only question around that is regarding having the player prefab within the scene. As far as I understand having the player prefab inside the scene means that it can't be set as the Player Prefab within the Settings tab of the Game Editor, from what I understand having the prefab inside the scene "overrides" what would be the player prefab.

    From what I've been able to read this doesn't matter too much for a FPS as opposed to the other game types. That said beyond the playerstart would there be any particular pitfalls to this method ie issues with inventory? or ability to perform checks against actions the player has done or something? or is this a fine way to do it?

    Thanks again

  • That's correct - a local Player will override the prefab assigned in the Settings Manager for the duration of that scene.

    Whether or not that affects your logic, though, depends where the logic is stored. If you're using a Variables component attached to the Player, then those values will be unique to the scene. For any other variable source (Local / Global), there should be no difference.

    If you wanted to be super-safe and leave the Player outside of the scene, you can also attach a custom script to your outer Hotspots that assign the "Limit to camera" field to the Fist Person Camera automatically when the scene begins:

    using UnityEngine;
    using AC;
    
    public class LimitToFirstPersonCamera : PlayerInput
    {
    
        void OnEnable () { EventManager.OnPlayerSpawn += OnPlayerSpawn; }
        void OnDisable () { EventManager.OnPlayerSpawn -= OnPlayerSpawn; }
    
        void OnPlayerSpawn (Player player)
        {
            GetComponent<Hotspot>().limitToCamera = KickStarter.player.FirstPersonCamera;
        }
    
    }
    
  • Thank you Chris

    This was all very helpful. I've Implemented some of the above and the hotspots/cameras are working like a charm now

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.