In this sample, you may use the setLookat function to have the actor look at
the mouse cursor when the actor is in idle motion or when the project plays
back. The reaction area can be limited to within the web player only or the entire
screen.
Using the setLookat Function
Look-At Mode
Look-At Strength
Controls Behaviors
This sample contains 6 buttons, their behaviors are:
Click the first button, Screen Mode, to have the actor look at
the cursor within the screen area.
Click the second button, Player Mode, to have the actor look at
the cursor within the player area.
Click the third button, None, to stop the actor from looking at the
cursor.
Click the forth button, Mild, to set weakest look-at
movements to the head and eyes of the character, which is suitable for
real humans.
Click the fifth button, Medium, to set medium look-at
movements to the head and eyes of the character .
Click the sixth button, Strong, to set strongest look-at
movements to the head and eyes of the character, which is suitable for
cartoon or non-human characters.
Copy and paste the code in-between the <head> and
</head>
tags of your custom web page.
The purposes of the functions:
$(function ():
This function defines the address, the position of
the CrazyTalk Web Player in the custom web
and loads another actor (Wife.uctmodel); meanwhile, assigns an idle motion (Exhausted.uctidle) to the newly loaded actor.
functionSetScreen(): This function
sets the look-at reaction area to the entire
screen.
functionSetPlayer(): This function
sets the look-at reaction area to the web player
only.
functionSetNone(): This function
turns off the look-at feature of the actor.
functionSetMild(): This function
sets weakest look-at strength.
functionSetMedium(): This
function sets medium look-at strength.
functionSetStrong(): This
function sets strongest look-at strength.
The adjustable code in the functions: $(function ()
Replace the below address of the CrazyTalk Web Player with the one within your self-hosting
server. https://www.reallusion.com/crazytalk/Unity/samplecode/CTWebPlayer.unity3d
Replace the below address of the *.uctmodel files with the one
where you have uploaded your custom actor. https://www.reallusion.com/crazytalk/Unity/samplecode/SampleCode9/Interaction_lookat.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 or
false) value determines if the character will be shown
or hidden when the project is loaded.
function setScreen(),
setPlayer() and
setNone()
Change the string in the setLookAt function to
"screen",
"player" or
"none" to determine if the character will look at the cursor
within the entire screen, merely within the player, or not to look at
the cursor at all.
functionsetMild(),
setMedium() and
setStrong()
Change the string in the setLookatStrength function to
"mild",
"medium" or
"strong" to determine if the character will look at the cursor
with hard.
Copy and paste the code from <div>
to </div> into the position
where you want to embed the web player in-between the
<body> and </body>
tags of your custom web page.
Modify the numbers after the width: and
height: parameters in the first line to customize
the size of the player.
Controls for Setting Look-at Modes
Copy the
<input.../> lines to the positions
where you want to embed the buttons in-between the
<body> and
</body> tags of
your custom web page.
Please note that:
The function and the button that calls it must be
individually put within the head and body blocks in pairs.
You can only copy and paste the desired buttons and the functions to your custom web pages.
These six <input.../> lines form
six buttons on the web. Each of them will call the function declared
within the head block after being clicked.