Skip to content

Action Triggers

Amethyst-szs edited this page Dec 8, 2023 · 6 revisions

Introduction

There are various ways to control what CameraActions are enabled in your scene (including writing your own code and calling the start() and end() methods on the CameraActions yourself!) but the plugin includes lots of different controllers and triggers as well.

Camera Area 2D

Inherits Area2D

The CameraArea2D is an Area2D-based node that handles camera actions defined by any CamereAction and a CollisionShape2D or CollisionPolygon2D.

There are two additional properties in a CameraArea2D you can modify through the Inspector: target – which node activates this area and allow_any – whether the CameraArea2D should ignore the filter.

When the target area or body for (or any if allow_any is enabled) enters the area, the CameraAction is activated. When that object leaves the area, the action will be stopped. Standard priority rules apply.

Camera Action Switch

Inherits Node2D

The CameraActionSwitch node switches from one action to another. Only one action in a switch can be enabled at any given time.

By default, the CameraActionSwitch's action list must be manually filled. Optionally, it's possible to use the CameraActionSwithch's children instead. This list can be modified at runtime if using the manual list.

To use this node you'll need three methods:

start_by_index(index: int): Start an action in the switch by its index in the list.

start_by_node_name(name: String): Start an action in the list by its name, this is not case-sensitive.

end_active(): Disable the CameraActionSwitch's currently enabled action.

Camera Action Sequence

Inherits CameraActionSwitch

The CameraActionSequence node transitions between different camera actions in a specific order, useful for animations and cutscenes. Uses the same list system as CameraActionSwitch.

There are four different looping modes for how the sequence should behave when reaching the end, detailed below:

  • End: Become inactive until started again, disabling all of its camera actions.
  • Repeat: Go back to the first action in the list and continue.
  • Ping-pong Once: Go through the list forward and backward, ending after one full cycle.
  • Ping-pong: Go through the list, bouncing back and fourth through the list.

CameraActionSequence supports autostart, as well as automatic progression through the sequence by an interval. If the interval equals 0 the sequence won't automatically progress (this is the default behavior).

To use this node in code you'll need a couple methods:

sequence_start(): Go to the first item in the sequence list and start it.

sequence_step(step: int = 1): Progress through the sequence by step (step defaults to 1, only change this to skip elements in the sequence).

sequence_set(index: int): Skip to a specific index in the sequence and activate it.

sequence_end(): End and reset the sequence. Also disables the currently enabled camera action in the sequence if there is one.

sequence_pause(): Stop the sequence but hold on to the current position, can be restarted using sequence_resume().

sequence_resume(): Start the sequence from the last position it was in, meant to be used with sequence_pause().

Clone this wiki locally