0
\$\begingroup\$

I created a Prefab called White Letter and added an Animator to it to create the illusion of falling letters.

I use this Prefab to generate words; here's an animated gif of what it looks like in action:

enter image description here

The animation basically turns the Mesh Renderer On and Enables the Audio Source, and then dynamically alters the Font Size and Offset over 30 frames to make it look like it's falling:

enter image description here

enter image description here

I took each of the White Letters (and the dot) and put them into a List of GameObjects. Then "For Each" GameObject on the List, I triggered the animation.

The problem I'm running into is that at first, all of the animations ran at the same time. So to get around that, I added a "Wait for 1 second" to the end of my For Each loop.

This worked but is not elegant and doesn't offer fine-grained control over the animation timings.

Ideally I would like to have better control over the animation timing. For example, I'd like the X to fall... and then at a certain frame of its fall, I'd like to trigger the animation for the next letter (the dot). Etcetera.

Basically while the Animator of one GameObject is executing, I'd like to be able to trigger the Animator of the next GameObject (in my list).

Any advice on how to achieve this?

\$\endgroup\$
6
  • \$\begingroup\$ This sounds like just adjusting the value of WaitForSeconds to be a fraction of your animation length. Where do you need help achieving that? \$\endgroup\$
    – DMGregory
    Apr 13, 2023 at 19:14
  • \$\begingroup\$ When I lower the value of WaitForSeconds to be a fraction of my animation length, multiple letters appear and start falling at the same time. So was hoping to be able to have each animation trigger the next... \$\endgroup\$
    – kanamekun
    Apr 13, 2023 at 19:20
  • \$\begingroup\$ So then you'd yield until the end of the animation, so, same question: where did you run into difficulty writing that code? What step do you need help with? \$\endgroup\$
    – DMGregory
    Apr 13, 2023 at 19:52
  • \$\begingroup\$ I'd like to have the option to start the second animation before the first animation is done. Is it possible to trigger a second gameobject's animation from within the first animation? \$\endgroup\$
    – kanamekun
    Apr 13, 2023 at 19:56
  • \$\begingroup\$ How familiar are you with Animation Events? \$\endgroup\$
    – DMGregory
    Apr 13, 2023 at 20:55

1 Answer 1

1
\$\begingroup\$

If you had a fixed sequence of falling glyphs, then I would do this with the optional Timeline package. But due to the fact that you want to support arbitraty strings of unknown length, this isn't going to work too well, because you would need to create a separate timeline for each string. Well, you could generate the timeline procedurally, but then you would miss out on the visual editor, which is the main reason to use this in the first place.

So in this case I would recommend to use animation events. Animation events allow you to place points in the Animation window which trigger C# methods when reached. So you can have the animation for an individual glyph and at (or near) the end of the animation place the animation event that calls the method which spawns the next glyph in the string.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .