1. Star Child
  2. News
  3. Star Child Dev Log #31

Star Child Dev Log #31

Jay Ingle - lead developer, designer, and artist:

Let us take a look at the process of animating some plants. In the world of Star Child, we don't always have a lot of scrolling/parallax going on, so we need to find ways to make things move, to provide pleasing visual interest.

We want all plants to move a little when you touch them, or when a rocket flies past them. This looks neat, but also makes you feel like you are IN this world, a part of this world, affecting things with your actions and movements.

We also want plants to sway in the correct direction. Some plants are small enough where we can just give them a little dip, and not have to animate and code them to work in two different directions. Such as these little bell plants:





Just a little animation for the little plants. Here is what is interesting: the closer the size of the plant to the player, the more animation is needed. Small plants only need small animations. BIG plants, since they are heavier, are less affected by our movement, and thus they don't move a whole lot when we touch them.





However, animation speed should be faster for the smaller plants, and slower for the big plants. When we combine several of these plants, the effect can be quite nice, and seem natural. Notice that the middle-sized plant has the most frames of animation, and moves the most when we touch it.



Here is the bit of code that runs whenever something touches a plant:



We check if the animation is already playing, because we don't want to skip back to the first frame to start the animation over, if it is already in the middle, that looks quite strange.

We then randomize the speed of the animation, from 0.8 (80% speed) to 1.2 (120% speed). This is per-plant, so each plant will animate at a slightly different rate, even if they are the same size.

Next we check the relative location of the "body" that has interacted with the plant. "body" is gdscript terminology, it generally refers to things that exist in the physics simulation, and move around in the world. A physics body. Could be the player, could be a rocket, could be an enemy, etc.

If the body's horizontal (x) position is greater than the plant's position (global_position.x in this case), that means the body is further to the right than the plant (and must be moving left into the plant's hitbox), and thus, we sway the plant to the left.

These plants that I have shown have been limited in their animation techniques. This is due to the small size, or their solid-ish nature. Tune in next week and we will go thru the entire process of creating some plant animations, for plants that bend and move a lot more.