RigEye2D Godot Plugin
What is this?
Tool scene for Godot Engine that helps with making moving animatable eyes in 2D. Usable in games, animations, etc.
Features:
- Tracking any Node2D position
- Tracking mouse cursor
- Tracking fixed Vector2 position
- Pairing multiple RigEye2D nodes so they track target together
- Controlling speed of movement animation
- Controlling FPS of animation to make stylized movement
- Preview movement in Godot editor
- Providing signals
- Providing API of different methods
- Simple to extend
- Simple to modify
Supported Godot versions
- 4.7
- 4.6
Quick Start
- Download this plugin inside Godot Engine from Asset Store (AssetLib in 4.6), or download latest release from GitHub and place it in "addons" dir of your project
- Enable the plugin in
Project -> Project Settings -> Plugins - Make "New Inherited Scene" from rig_eye_2d.tscn in the plugin
scenesdir - Set textures for Sprite2D nodes of eye parts White/Iris/Pupil, only those you require (plugin includes example AtlasTexture for all parts)
- Enable
Process In EditorandTracking -> Track Mouseto see movement - Play with options to configure behaviour to your needs
- Save as your own scene and instantiate as many instances as you require
More info and examples in video: coming soon
API DOC
Targeting priority
Each eye can resolve its own look target from one of three sources: a manual point (look_at_point()), a tracked Node2D (target_path / set_target()), or the mouse cursor (track_mouse). When several of these are active at once on the same eye, or across a group of paired eyes, the eye that ends up driving the whole group's movement is decided by priority:
- Manual point (
look_at_point()) - highest priority. - Node target (
target/set_target()) - Mouse cursor (
track_mouse) - lowest priority.
This matters most for paired eyes: the entire group looks at whichever active mode has the highest priority among any eye in the group, not just its own. For example, if eye_a is paired with eye_b, and eye_a.track_mouse = true while eye_b.set_target(some_node) is called, the whole pair will track some_node - the node target on eye_b outranks the mouse tracking on eye_a. If no eye in the group has an active target, they rest at center.
Signals
move_started()
Emits when an eye element starts moving away from its resting position.
move_finished()
Emits when all eye elements settle and stop moving.
target_changed(old_target: Node2D, new_target: Node2D)
Emits whenever the tracked target node changes. Useful for reacting when character switches to look on a new object.
tracking_changed(mode: TrackingMode)
Emits whenever the active TrackingMode (NONE, NODE, MOUSE, POINT) changes.
Methods
set_target(node: Node2D, property_name: StringName = &"") -> void
Sets a Node2D for the eye to track, following its global_position or an optional custom property. If this eye is paired, the target is shared with all paired eyes.
Arguments
node- theNode2Dto look at.property_name- optionalVector2property onnodeto track instead ofglobal_position.
look_at_point(world_position: Vector2) -> void
Like set_target(), but tracks a fixed Vector2 world position instead of a node. If this eye is paired, the point is shared with all paired eyes.
Arguments
world_position- the world-space point to look at.
clear_target() -> void
Clears the current tracking target for this eye and any paired eyes.
snap_to_center() -> void
Instantly resets all eye elements to center without animating.
pair_eye(eye: RigEye2D) -> void
Mutually pairs this eye with another RigEye2D, adding each to the other's paired_eyes so both track the same target and move in sync.
Arguments
eye- the otherRigEye2Dinstance to pair with.
Pairing 3+ eyes:
pair_eye()only creates a direct link between the two eyes you call it on - it does not chain through to eyes they're already paired with. For a group of 3+ eyes to move in sync, pair every eye with every other eye in the group usingpair_group()
Skipping pairing
eye_awitheye_ccan cause jittery movement, since each eye only computes the synced look target from its ownpaired_eyeslist!
unpair_eye(eye: RigEye2D) -> void
Mutually unpairs this eye from another RigEye2D, removing each from the other's paired_eyes.
Arguments
eye- the previously pairedRigEye2Dinstance to detach.
Unpairing from a group of 3+:
unpair_eye()only removes single link to the giveneye- if this eye is still paired with other RigEye2D instances, it will keep moving together with them! If you want this eye fully detached from whole group it's in, useclear_pairs()instead.
clear_pairs() -> void
Mutually removes this eye from all of its paired_eyes, fully detaching it from the group.
pair_group(eyes: Array[RigEye2D]) -> void
Pairs every eye in the given list with every other eye in the list, a shortcut for manually pairing every combination in a group of 3+ eyes.
Arguments
eyes- the otherRigEye2Dinstances to pair into one group together with this eye.
unpair_group(eyes: Array[RigEye2D]) -> void
Unpairs every eye in the given list from every other eye in the list, a shortcut for manually unpairing combination in a group. To clear eye from all groups faster, use clear_pairs()
Arguments
eyes- the otherRigEye2Dinstances to unpair from this eye and from each other.
get_eye_position(element: EyePart) -> Vector2
Returns the current local-space position of the given eye element. Can be used for projectile targeting, etc.
Arguments
element- which part to query:EyePart.WHITE,EyePart.IRIS, orEyePart.PUPIL.
get_eye_sprite(element: EyePart) -> Sprite2D
Returns Sprite2D node for the given eye element.
Arguments
element- which part's sprite to retrieve:EyePart.WHITE,EyePart.IRIS, orEyePart.PUPIL.
get_eye_node(element: EyePart) -> Node2D
Returns the Node2D movement container for the given eye element. Useful when you need a reference to the node being moved by the plugin, e.g. to attach children to it at runtime.
Arguments
element- which part's container to retrieve:EyePart.WHITE,EyePart.IRIS, orEyePart.PUPIL.
anim_set_target(node_path: NodePath, property_name: StringName = &"") -> void
Animation-friendly wrapper for set_target() that takes a NodePath, since AnimationPlayer tracks can't store live node references.
Arguments
node_path- path to theNode2Dto look at.property_name- same asset_target().
anim_pair_eye(eye_path: NodePath) -> void
Animation-friendly wrapper for pair_eye() for use in AnimationPlayer Call Method tracks.
Arguments
eye_path- path to theRigEye2Dnode to pair with.
anim_unpair_eye(eye_path: NodePath) -> void
Animation-friendly wrapper for unpair_eye() for use in AnimationPlayer Call Method tracks.
Arguments
eye_path- path to theRigEye2Dnode to unpair.
Changelog for version v1.0.0
No changelog provided for this version.