February
01
2014

You can use any control you like with ORK Framework – you just need to let ORK know.

ORK Framework’s built in controls are a good starting point to get you going, but most likely you’ll want to add your own control scripts for player or camera control. Since ORK needs to enable/disable control at certain points in a game (e.g. during a cut-scene event or a battle without direct player control), you need to set up the name of your control scripts on the player or camera, to allow ORK accessing it.

The game controls are set up in the ORK Framework editor in Base/Controls > Game Controls. To set up the player or camera controls for using custom controls, change the following settings.

  • Control Type
    Select None.

Now, click on Add Custom Control in the Custom Control settings to add information about your custom control script.

  • Blocked By
    Select if the control script is blocked with the Player or Camera controls.
  • Placed On
    Select if the control script is placed on the Player or Camera.
  • Behaviour Name
    Set it to the name of your script.
    E.g. your script’s name is CustomControl.cs (and the name of the class is CustomControl), you need to set the name to CustomControl.
  • Add Component
    If your control script is already added to your player/camera, disable this setting.
    If you want ORK Framework to automatically add the script to the player/camera, enable this setting.

And that’s it – there are additional settings for control scripts that are placed on child objects of the player/camera, and you can set initial fields and parameters of the script.

howto_custom_controls1

Wrapper Components

In case your control component needs some kind of special treatment or setup that doesn’t work well with ORK’s custom control setup, consider writing a wrapper component.

A wrapper component works as a bridge between ORK and your custom control. You’d define the wrapper component in ORK’s custom control and manage blocking and unblocking the custom control in your wrapper component.

When ORK blocks a control, the component will be disabled, so you’ll use the OnDisable function of the component:

When ORK unblocks a control, the component will be enabled, so you’ll use the OnEnable function of the component:

You can also add these functions to your actual custom control component and skip using a wrapper component.

Example: OOTII Camera Controller

Here’s an example wrapper component for OOTII Camera Controller. This wrapper will forward control blocks supports Camera Control Target changes and transitions, you can download it here:

Download

In case transitions are not working, make sure the wrapper component is executed after the actual camera control component by adding it to the Script Execution Order. You can do this in Unity’s Project Settings, add the ORKCameraControlWrapper component with a time of 100 (or more).

The wrapper component has settings for resetting the camera’s position and rotation after restoring camera control (to the position/rotation it had when the camera control was blocked). This can be done using local or world space. For OOTII, the camera is usually a child object of the camera controller – the default setup is to restoring position/rotation in local space.

Setup

To set it up in ORK Framework, go to Base/Control > Game Controls in the ORK editor.

Camera Controls

Disable built-in camera controls.

  • Camera Control Type
    Select None.

Custom Controls

Click on Add Custom Control and change the following settings.

  • Blocked By
    Select Camera.
  • Placed On
    Select Camera.
  • Behaviour Name
    Set to ORKCameraControlWrapper.
  • From Root
    Enable this setting.
  • On Child Object
    Enable this setting.
  • Add Component
    Enable this setting.

And that’s it – don’t forget to save. ORK will now add the control wrapper to the camera when loading the scene, which will handle blocking camera controls, camera target changes and target change transitions for you. No need to do any further setup.

Script

The script looks like this – you can use it do wrap other custom camera controls as well by changing the OOTII related code to your custom control’s code.