WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Check if an avatar has a state "123" (https://forum.worldviz.com/showthread.php?t=2676)

Josh 04-06-2010 11:39 AM

Check if an avatar has a state "123"
 
Hi all

when setting an avatar's state, worldwiz doesn't actually seem to check whether the avatar's really has this state. So

avatar.state(123)

doesn't result in a failure when the avatar doesn't have a state with number 123 - the avatar just doesn't do any animation.

Is there a way to determine whether the avatar has the state 123? Something like

avatar.has_state(123) # True / False

? Thanks for help,
Josh

Jeff 04-06-2010 01:11 PM

You could use .getAnimationList and check the length of the list returned. If the ID is greater then that length the animation is not defined.
Code:

animations = avatar.getAnimationList()
if 123 <= len(animations):
        avatar.state(123)
else:
        print 'The avatar does not have this animation id'



All times are GMT -7. The time now is 08:20 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC