Forum rules - please read before posting.

Object: Send Message custom script problem

This is the script I haven't been able to get to work:
using UnityEngine;
using System.Collections;
namespace AC {
public class SetLimitCamera : MonoBehaviour {
void Start () {
}
void Update () {
}
void SetLimitCam () {
GetComponent<Hotspot>().LimitToCamera(GameObject.Find(GlobalVariables.GetPopupValue (5)).GetComponent<_Camera>());

}
}
Its purpose is to make a hotspot visible through the active camera.

In the action list of the trigger that is activated on entering an area; 
the camera is switched to,
 a global variable is set to the name of this camera
 and Object : Send Message is called for each hotspot I want to be visible; using SetLimitCam as defined above.

Not errors are flagged but this appears to have no effect on hotspot visibility.
Any suggestions?

Comments

  • I just discovered the Limit Visibility script in the manual. I will post again if that doesn't solve my problem.
  • I'm afraid that didn't work either. This is the simplified code:
    using UnityEngine;
    using System.Collections;
    namespace AC {
    public class SetLimitCamera : MonoBehaviour {
    void Start () {
    }
    void Update () {
    }
    void SetLimitCam (int on) {
    if (on == 0) {
    GetComponent<LimitVisibility> ().enabled = false;
    } else
    GetComponent<LimitVisibility> ().enabled = true;
    }

    }
    The camera in the Hotspot limit camera is represented by the '0' value and the Limit Visibility camera by the '1' value. I was hoping that by enabling the limit visiblity component it would change the active camera and by disabling it I could change it back. Sadly it is behaving just as before; No error message and no effect. Any pointers would be welcome.

  • The Limit Visibility script refers to purely visual visibility, not interactive.  Are you using v1.46?  The latest release introduced this exact feature into the Hotspot's Inspector: you can use it to limit a Hotspot's interactivity to a set camera.
  • I am using v1.46d. I need to switch hotspot visibility between two cameras dynamically as I have one scene with several rooms connected by doorways. Each room has a a camera and I can get the camera to switch using triggers as you show in your tutorials. The issue is that with that many rooms and doors I want only the door hotspots for the current room to be visible from that room's camera. 
    I was trying to update the relevant hotspots in my first example above.
    I'm in work at the moment but I will try to answer any questions you have about what I've done.
    Thanks for looking at this Chris. 
  • The best way would be to alter the Hotspot's "Limit to camera" field using a custom Action, in that case, e.g.:

    myHotspot.limitToCamera = myNewCamera;

    That would go in the Run() function of a custom action.
  • Thanks Chris. It's a lot clearer now and it's almost working. 
    I will raise another question if I can't figure out how to stop the hotspots from becoming deactivated, 
    but I will try to figure it out for myself first. 
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.