Forum rules - please read before posting.

Possible Bug in HeadTurnTrack & Improvement

Hi,
I don't know what the actual reason for this is, but in HeadTurnMixer.cs I had to replace:

if (_character == null)
{
    GameObject characterObject = playerData as GameObject;
    if (characterObject)
    {
        _character = characterObject.GetComponent<AC.Char>();
    }
}

with

if (_character == null)
    _character = playerData as Char;

as characterObject was always "null" (like I said i have no idea why this happens, but with the small change it works)

I also added the following improvement to the HeadTurnTrack.cs, this might be helpful for others too, as it displays the target and the offset on the actual clip.

public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount)
        {
            foreach (var c in GetClips())
            {
                HeadTurnShot headTurnShot = (HeadTurnShot)c.asset;
                c.displayName = "Target: " + headTurnShot.headTurnTarget.Resolve(graph.GetResolver()).name + "; Offset: " + headTurnShot.localSpaceOffset;
            }

            ScriptPlayable<HeadTurnMixer> mixer = ScriptPlayable<HeadTurnMixer>.Create (graph);
            mixer.SetInputCount (inputCount);
            return mixer;
        }

Cheers,

Onat

Comments

  • Thanks for the details.

    Could you describe the way you've set up your track? Are you re-binding it at runtime, etc? It's not an issue I've encountered myself, though I expect there'd be no issue with combining both assign methods.

  • Hi Chris, in my game I'm pretty much rebinding everything in runtime, although for testing purposes I just created a timeline with a head-turn track, and manually assigned a character and a head-turn clip to it. As i said, it's very weird because when I attach my editor and debug line by line, I can see that the character is recognized, but characterobject remains "null". I can try test in a fresh project just importing my character etc., maybe this will give us some more insight.
    By the way, I posted the improvement prematurely... it needs a null check for the headturntarget, otherwise it will spam the editor with errors if there is no target assigned :D

  • Try this, which should use the original as a fail-safe:

    if (_character == null)
    {
        if (_character == null)
            _character = playerData as Char;
        if (_character == null)
        {
            GameObject characterObject = playerData as GameObject;
            if (characterObject)
            {
                _character = characterObject.GetComponent<AC.Char>();
            }
        }
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.