topical media & game development
lib-unity-demo-character-unity-Assets-VirtualWorldExample-Character.js / js
var character : String;
var config : String;
var anim : String = "walk";
// Allow the CharacterElementDatabase to be downloaded.
while (!CharacterGenerator.ReadyToUse) yield;
// Configure a CharacterGenerator according to the configuration strings.
if (character == "")
generator = CharacterGenerator.CreateWithRandomConfig();
else if (config == "")
generator = CharacterGenerator.CreateWithRandomConfig(character);
else
generator = CharacterGenerator.CreateWithConfig(character + "|" + config);
// Give the particle system some time to grow.
yield WaitForSeconds(2);
// Wait for the assets to be downloaded.
while (!generator.ConfigReady) yield;
// Create the character.
go = generator.Generate();
// Attach the character to this prefab so we can move it around.
go.transform.parent = transform;
go.transform.localPosition = Vector3.zero;
go.transform.localRotation = Quaternion.identity;
// Play and loop the specified animation.
go.animation.Play(anim);
go.animation[anim].wrapMode = WrapMode.Loop;
// Stop emitting particles, as the character now exists.
GetComponentInChildren(ParticleEmitter).emit = false;
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.