It could be tedious to manually specify positions for aligning bubble printers with the associated actors all the time.
We don't provide an out-of-the-box solution for this in Naninovel due to the amount of possible combinations for that kind of text presentation multiplied by all the possible character implementations, making it impractical to cater for all of them. Instead, use existing hooks and features to construct a solution tailored for your specific needs.
Below is a basic example for Naninovel v1.20 to help you get started.
Create following components:
Code: Select all
using System.Collections.Generic;
using UnityEngine;
public class Anchor : MonoBehaviour
{
public string Id;
private static readonly Dictionary<string, Transform> anchors =
new Dictionary<string, Transform>();
public static bool TryGet (string id, out Transform anchor) =>
anchors.TryGetValue(id, out anchor);
private void OnEnable () => anchors[Id] = transform;
private void OnDisable () => anchors.Remove(Id);
}
Code: Select all
using UnityEngine;
public class AnchorFollower : MonoBehaviour
{
public string Id;
public void Follow ()
{
if (Anchor.TryGet(Id, out var anchor))
transform.position = anchor.position;
}
}
Now add Anchor
component to a game object inside character prefab to which bubble printer should be attached. This requires using an actor implementation which allows compositing its contents, such as layered, generic, live2d, etc. Assign the ID property with an unique identifier. Position the game object to the point where you'd like to anchor the bubble.
Next create a custom bubble printer from template (Create -> Naninovel -> Text Printers -> Bubble
) and attach AnchorFollower
component to the Content
object inside the printer prefab. Enter the same ID assigned to the char anchor.
Attach Follow()
handler of the follower component to On Show
and On Reveal Started
events of the text printer.
For convenience, you can as well link the printer to associated character, so that it'd activate (show/hide) when the author is speaking, w/o the need to manually activate it via @printer
command.
Now our bubble printer will "follow" the character anchor whenever it's showed or starts revealing the text.