Topic: Character Flash

I was wondering if anyone had tips on making the characters flash during a move?
Im trying to implement a Fantasy Strike style system where the colour of an outline flash tells the player what state they're in.

Share

Thumbs up Thumbs down

Re: Character Flash

On the Character prefab include a custom script that looks for the OnMove() event. Flag that a specific move is happening then in the Update of that script run the code you need based on that flag.

If it's a state thing you can just use the Update to get the character's control script which has their currentState and can do code from there.

Share

Thumbs up +2 Thumbs down

Re: Character Flash

Thanks, Ill try that. Now I just need to get the flashing outline itself.
Hopefully I can get it to work with my existing shaders, they seem flexible enough.

Share

Thumbs up Thumbs down

4 (edited by Steviebops 2020-08-04 18:03:29)

Re: Character Flash

Updated with the current solution Im using. It's still an early version, it just flashes, there's no link to move frames, that will come later.

using UFE3D;
using UnityEngine;
public class OutlineFlash : MonoBehaviour
{
    public Color baseColor;
    public Color targetColor;
    Color lerpColor;
    public bool flash = false;
    public Renderer rend;   

    void Update()
    {
        if (flash == true)
        {
            lerpColor = Color.Lerp(baseColor, targetColor, Mathf.PingPong(Time.time *10, 1));
            rend.material.SetColor("_OutlineColor", lerpColor);
        }
        else
        {
            rend.material.SetColor("_OutlineColor", baseColor);
        }
    }
}

And I call this method in ConstrolsScript

 public void CheckFlashing(OutlineFlash outlineFlash)
    {  
        //start and stop outline flashing
        if (currentMove != null && currentMove.name == ("Cut Head"))
        {
            moveFlash.flash = true;
        }
        else 
        {
            moveFlash.flash = false;
        }
    }

OutlineFlash script is added to each prefab and the Renderer is set in the inspector.

Goals for expansion will be to affect multiple renderers for each body part, control it with specific key frames and to have multiple colors, one for each state I need to show.

Share

Thumbs up Thumbs down

Re: Character Flash

In CheckFlashing you can simplify it to one line:

moveFlash.flash = currentMove != null && currentMove.name == "Cut Head";


Also you might want to use currentMove.moveName instead, as name is the name of the GameObject as it appears in the Hierarchy, which would most likely be your character's prefab name or "Player #".

Share

Thumbs up +1 Thumbs down

Re: Character Flash

Check flashing currently looks like this

 public void CheckFlashing(OutlineFlash outlineFlash)
    {
        //start and stop outline flashing
        if (currentMove != null && (currentMove.currentFrameData == CurrentFrameData.ActiveFrames || currentMove.currentFrameData == CurrentFrameData.StartupFrames))
        {
            foreach (Hit hit in currentMove.hits)
            {
                if (hit.unblockable)
                {
                    outlineFlash.targetColor = Color.red;
                }
                else
                {
                    switch (hit.hitType)
                    {
                        case HitType.HighLeft:
                            outlineFlash.targetColor = Color.green;
                            break;
                        case HitType.HighRight:
                            outlineFlash.targetColor = Color.green;
                            break;
                        case HitType.LowLeft:
                            outlineFlash.targetColor = Color.yellow;
                            break;
                        case HitType.LowRight:
                            outlineFlash.targetColor = Color.yellow;
                            break;
                        default:
                            outlineFlash.targetColor = Color.white;
                            break;
                    }
                }
            }

            moveFlash.flash = true;
        }

        else
        {
            moveFlash.flash = false;
        }
    }

Character flashes based on two conditions, the type of hit and whether or not the move is in startup or active frames.

Share

Thumbs up +1 Thumbs down