Interaction Function

Advanced Function

Loading Actors

In this sample, you may use the loadActor function to toggle and load different
actors
by pressing buttons with specific behaviors. Copy and paste the code to your custom web page
so that you can have different characters talking in identical scenarios.

Using the loadActor Function

Controls Behaviors

This sample contains 2 buttons, their behaviors are:

Click the first button, Actor1, to load and show the first
actor (Actor.uctmodel) with idle motion (CTDefWebPreview.uctidle) after the playback stops.

Click the second button, Actor2, to load and show the second
actor (Actor2.uctmodel) with a message shown in the Console panel
of your web browser after the actor is loaded. However, the actor is not
assigned with
any idle motion after the playback stops.

functionActor2(): This function loads another
actor (Actor2.uctmodel) without idle motion. In addition, it also pops up a messsage text,
Actor loaded!, in the console panel.

The adjustable codes in the functions:$(function ()

Replace the below address of the CrazyTalk Web Player with the one within your self-hosting
server.http://www.reallusion.com/crazytalk/Unity/samplecode/CTWebPlayer.unity3d

player.loadProject(){...}:
For more information about the modification method for the default project function, please refer to the
Sample Code 3 - Load Projects section.

functionActor1 and Actor2

Replace the below addresses of the *.uctmodel files with the ones
where you have uploaded your custom actors.
In Actor1: http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode4/Actor3.uctmodel
In Actor2: http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode4/Actor2.uctmodel

Note:

If the custom actor files are uploaded to the identical server where your custom web
pages are, then simply change the entire
addresses (http://...uctmodel) to
the file names of the custom actors.

Otherwise, you must replace the
entire addresses with the complete addresses
(URL) of the custom actor files.

showActor: The Boolean (true for
false) value determines if the character will be shown
or hidden when the project is loaded.

functionActor1

idleMotionUrl: Replace the below address of the *.uctidle file with the one
where you have uploaded your custom idle motion.http://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode4/Affirmative.uctidle

Note:

If the idle motion file is uploaded to the identical server where your custom web
pages are, then simply change the entire
address (http://...uctidle) to the file name of the
custom idle motion.

Otherwise, you must replace the
entire address with the complete address
(URL) of the idle motion file.

functionActor2

loaded: function (status) {}: If you want to execute more commands, functions or
methods after the custom actor is loaded, then add them into this function in-between the curly brackets.
They will instantly be executed after the custom
actor is loaded.
In this case, the console panel will display Actor loaded!.