Camera feature

From DF21 Wiki

In vanilla Dark Forces, the camera ("EYE") is usually attached to the same object as the PLAYER, meaning that the level is viewed from the perspective of the player. It is possible for the camera to be placed on a non-player object, allowing for a third-person rather than first-person experience -- this is exploited in some mods (eg. Dark Tide, Enter the Kell Dragon).

TFE now allows the camera to be moved to a different object at any time during gameplay. This allows for various effects such as

  • Being able to look through security cameras
  • Better in-game "cutscenes" / cinematic sequences
  • The ability to switch between first-person and third-person perspectives

See also: VUE Camera transforms

There are two ways to move the camera: via INF, or via ForceScript.

The camera (Eye) can be moved to any kind of object: a Spirit (invisible), an enemy, a scenery, a 3DO, etc. Be warned that if the object is destroyed while the camera is on it (eg. the enemy is killed) the game will crash.

Moving the camera with INF

The first step is to designate an object as a camera. This is done in the O file by using the new keyword CAMERA as follows.

CLASS: 3D      DATA:  0 X: 160.00 Y: -18.00 Z: 332.00 PCH: -25.00 YAW: 90.00 ROL: 0.00  DIFF: 1
 SEQ
  CAMERA
 SEQEND

A new CAMERA message has been added to INF. It can be sent the same way as other messages, either from a trigger or from an elevator stop. The following example shows it being sent from a trigger.

item: line   name: room1  num: 2
 seq
   class: trigger standard
     event_mask: 16
     client: camsec2
     message: CAMERA
 seqend

When the message is sent:

  • If the camera is currently on the player, the game will search the target sector ("camsec2" in this example) for a camera object. When it finds one, it will move the camera to that object. If no camera object is found in the target sector, nothing will happen.
  • If the camera is currently not on the player, the camera will be moved back to the player.

Moving the camera with ForceScript

To move the camera to an object with ForceScript, call the setCamera() function on that object.

myobject.setCamera();

To move the camera to the player, call setCamera() on the player.

player.setCamera();

Freezing the player

When the camera is not on the player, the player can ordinarily still move around, jump, shoot and so on. It might be desirable (eg. during a cutscene) to freeze the player's movement while the camera is somewhere else.

To do this, the disableActions() and enableActions() functions from the Player Script API can be used.

Other player actions

Night vision goggles are automatically disabled when the camera is not on the player.

Gas mask and headlamp are still usable when the camera is not on the player, and will continue to drain battery. (Headlamp light will not be visible.)

The player will still take damage and can be killed while the camera is somewhere else. If the player dies while the camera is somewhere else, the camera will be reset to the player when he respawns.

Enemy behaviour

As per default Dark Forces behaviour, enemies will shoot towards the camera (EYE) instead of the player. This is something that might be changed at a later point.