Had a rough time with Unity’s Avatar Masks

After successfully importing a few animation along with my proto typing Blueberry looking character, I quickly realized that I had to read up on Avatar Masks.

When the character is walking and attack animation is triggered, the walk freezes. Basically making the character look like it’s sliding for a brief moment.
After looking up forum posts and youtube videos, most of the information were on Avatar Masks using Humanoid Avatar type.
My Blueberry is using a Generic avatar. This meant that I have to manually select which bones to mask from the Transform menu within the Avatar Mask’s inspector/property.
My bones are generated using Blender’s Rigify and I haven’t looked deep into the bone relations. This gave me a hefty 6 hour troubleshooting session thinking I had something wrong elsewhere…

TLDR; I missed a few bones that were related to the upperbody animation which I had to have selected.

Simulating Day Night Cycle

This is a first attempt and test using the directional light

using UnityEngine;

public class DayNightCycle : MonoBehaviour
{
    [Header("Time Settings")] [Range(0, 24)]
    public float timeOfDay = 12.0f;
    
    // seconds in real time for a full day cycle
    public float dayDuration = 240.0f; 

    [Header("Sun Settings")] public Light sun;

    public Gradient sunColor;
    public AnimationCurve sunIntensity;

    [Header("Sky Settings")] public Material skyboxMaterial;

    public float maxAmbientIntensity = 1.0f;
    public Gradient ambientColor;

    void Update()
    {
        // Update time of day
        timeOfDay += Time.deltaTime / dayDuration * 24.0f;
        if (timeOfDay >= 24.0f) {
            timeOfDay -= 24.0f;
        }

        // Calculate sun rotation
        // 15 degrees per hour, offset to start at dawn
        var sunRotation = timeOfDay * 15.0f - 90.0f;

        // Apply rotation to the sun
        sun.transform.rotation = Quaternion.Euler(sunRotation, -30.0f, 0);

        // Update light color and intensity based on time of day
        var dayNightRatio = Mathf.InverseLerp(0, 24, timeOfDay);
        if (timeOfDay > 12) {
            dayNightRatio = Mathf.InverseLerp(24, 12, timeOfDay);
        }

        sun.color = sunColor.Evaluate(dayNightRatio);
        sun.intensity = sunIntensity.Evaluate(dayNightRatio);

        // Update ambient lighting
        RenderSettings.ambientLight = ambientColor.Evaluate(dayNightRatio);

        // Update skybox (if using a skybox that supports time of day)
        if (skyboxMaterial != null && skyboxMaterial.HasProperty("_Exposure")) {
            skyboxMaterial.SetFloat("_Exposure", sunIntensity.Evaluate(dayNightRatio));
        }
    }
}

2D Platformer: Health (Heart UI)

Changed the text based health system, to a heart sprite.
2 player health = 1 heart.
Used variables of fullHeart, halfHeart, and emptyHeart.
Once these values are detemined from the player’s currentHealth, and maxHealth, the heart prefabs are instantiated into a list and then displayed on the Canvas’ Grid Layout Group. Piece of the code I decided to go with.

    public void CreateHearts()
    {
        ClearHearts();

        float fullHearts = MathF.Floor(PlayerHealth.instance.health / 2);
        float emptyHearts = MathF.Floor((PlayerHealth.instance.maxHealth - PlayerHealth.instance.health) / 2);

        for (int i = 0; i < fullHearts; i++)
        {
            InstantiateHeart("Full");
        }
        if (PlayerHealth.instance.health % 2 != 0)
        {
            InstantiateHeart("Half");
        }
        for (int i = 0; i < emptyHearts; i++)
        {
            InstantiateHeart("Empty");
        }
    }