• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Typing on text—getting most recent character

New Here ,
Oct 08, 2018 Oct 08, 2018

Copy link to clipboard

Copied

Hi,

I feel like the answer to this is probably a resounding "no" but figured i'd ask out there for those who know buckets more than i do.

If i have a line of text typing on (say, with the typewriter effect) is there a way to recognize at any given time what the last character typed was?

(With the idea that then you could link an object property to a character—e.g. when an A is typed on, an object scale animation is activated.)

Thanks for any thoughts anyone has on this!

-tim.

TOPICS
Expressions

Views

371

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

First-- this feels like more of an Expressions question, not a scripting question.

This could be doable depending entirely on the method you use to have the text type on, and the start/end range selector values, and most of the values in the 'Advanced' dropdown of the range selector.

With just Typewriter, set to the defaults, which are:

  • Start: Animating 0% - 100%
  • End: 100%
  • Offset: 0%
  • Units: Percentage
  • Mode: Add
  • Shape: Square
  • Smooth / Ease High / Ease Low: 0%

You can use an expression like this to give you the most recent revealed character:

// Get the reference text content

var referenceText = thisComp.layer("Hi timhubner!").text.sourceText;

// Get the value of the animated Start selector

var selectorPct = thisComp.layer("Hi timhubner!").text.animator("Animator 1").selector("Range Selector 1").start;

// Get the index of the last shown character, based on the selector percentage and length of source text

var lastShownCharIndex = Math.round(selectorPct / 100 * referenceText.length);

// Get only the character from the index above

var lastCharacter = referenceText.charAt(lastShownCharIndex - 1);

Once you have it, then you can start exploring what you want it to do. Tiggering and playing back animation is a rabbit hole of loops and ifs and checks, so it may not be the best approach for what you're after, but this should be a good start to at least get that last character!

A gif of what this would look like is below. At the top is the 'Typewriter' effect on a text layer, and at the bottom I'm showing only the last character using the expression above.

last_character_2.gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 08, 2019 Jan 08, 2019

Copy link to clipboard

Copied

LATEST

Sorry for the slow reply, but thanks for the help!

That definitely gets me started down the right path.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines