Skip to content

HEOCamera

HEOCamera_1

HEOCamera is used to switch camera controls for visual purposes.
Using this component, camera can be switched in occasions such as event cut scenes, special camera works, and more purposes.
Switching camera will be done by HeliScript as explained later.

Label Default Function
Position 0,0,0 Stores the camera's global position
Rotation 0,0,0 Stores the camera's global rotation

Usage

1. Create an empty GameObject and attach the HEOCamera component to place in scene.

HEOCamera_2

As this object will be treated as a different Item than HEOField, this can be placed outside the World object.

HEOCamera_3

2. Implement the HeliScript for controlling camera

The object with HEOCamera attached will be output as an Item.
Therefore, Item class functions such as SetPos and SetQuaternion can be applied, added to Camera Functions.

Camera Functions

  1. bool SetCamera()
    Sets camera to the designated camera item.
    Return value is true if switching has succeeded, false if failed.

  2. void ResetCamera()
    Resets camera to the default camera following the player.

For example, the HeliScript using functions above is written as follows:

component EventCameraTest
{
    Item m_Camera;
    bool is_evented;
    float Timer;

    public EventCameraTest()
    {
        m_Camera = hsItemGet("CameraObj");
        is_evented = false;
    }

    public void Update()
    {
        Timer += 10*hsSystemGetDeltaTime();
        m_Camera.SetPos(makeVector3(7*hsMathSin(DEGtoRAD(Timer)),2,7*hsMathCos(DEGtoRAD(Timer))));
        m_Camera.SetQuaternion(makeQuaternionYRotation(DEGtoRAD(Timer + 180)));
    }

    public void ChangeCamera(string dummy){
        is_evented = !is_evented;
        if(is_evented){
            m_Camera.SetCamera();
        }else{
            m_Camera.ResetCamera();
        }
    }
}

The scene implementing this script is as the image below.
When the defined event camera is enabled, camera will pivot around the world center.
On the image below, the Sphere object has a CallScript attached to switch camera when clicked.

HEOCamera_4

HEOCamera_Result

Other Tips

The event camera has characteristics as following:

  • Player control will be affected by camera
  • When POV is switched to 1st person view, player will warp to the camera position

Therefore, it is advised to constraint UI / player controls while event camera is enabled to prevent unexpected movements.