[Extension] Headlook Controller Actions

Have you created Editor Extensions for Cinema Director? Share them here! Looking to integrate your product to Director or looking for support to your editor extension, let us know!

[Extension] Headlook Controller Actions

Postby TrickyHandz » Sun Dec 28, 2014 12:02 pm

The Head Look Controller package on the Asset Store provides some support for actions similar to Mecanim LookAtTarget(), without the need for a Unity Pro license. The package is available here: Head Look Controller.

The following Director events are provided to change the target transform that a rigged model is looking at. They are available as Actor Track Items, listed under "Head Look -> Change Target" and "Head Look -> Look Forward":

HL_ChangeTarget
Causes the head look controller to focus on the transform defined in the event
Code: Select all
using UnityEngine;
using System.Collections;
using CinemaDirector;

[CutsceneItemAttribute("Head Look", "Change Target", CutsceneItemGenre.ActorItem)]
public class HL_ChangeTarget : CinemaActorEvent
{
    // The transform the character will look at
    public Transform targetTransform;

    public override void Trigger(GameObject actor)
    {
        HeadLookController hlc = actor.GetComponent<HeadLookController>();

        if (!hlc.enabled)
            hlc.enabled = true;

        hlc.target = targetTransform.position;
    }
   
}


HL_LookForward
Causes the Head Look Controller to focus on a point in front of the "Character Head Bone" transform.
NOTE: This only works well when the character isn't moving.
Code: Select all
using UnityEngine;
using CinemaDirector;
using System.Collections;

[CutsceneItemAttribute("Head Look", "Look Foward", CutsceneItemGenre.ActorItem)]
public class HL_LookForward : CinemaActorEvent
{
    // The transform of the bone that
    // is controlling head position
    // and rotation
    public Transform characterHeadBone;

    public override void Trigger(GameObject Actor)
    {
        HeadLookController hlc = Actor.GetComponent<HeadLookController>();

        // Note, this techique only works while the
        // character is stationary.
        hlc.target = characterHeadBone.position + hlc.gameObject.transform.forward;
    }
}



One important thing to note is that the "Look Forward" only acts well when the character is stationary. I would recommend disabling the Head Look Controller during parts of the cutscene when it isn't needed and enabling it when you do.

Unity Package Download: Director Head Look Controller Events

If there are any questions, comments, suggestions and improvements, please post them.
TrickyHandz
 
Posts: 43
Joined: Sat Aug 02, 2014 8:25 am

Return to Editor Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron