Open topic with navigation
Now let's make the avatar walk to wherever we click on the ground. To do so, we need to register a function that will be called when a mouse button is clicked. We'll use vizact.onmousedown() for this.
Note: Python uses indentation as a structural element of the language. Make sure when writing your own code that the indentation is consistently either tabs or spaces, not mixed. You can make the tabs / whitespace visible in Vizard with View >Whitespace.
When the left mouse button is clicked the function avatarWalk() is called. The first part of the code simply checks that the user clicked on the ground. If it was, then a walkTo action is created to the point that was clicked. Then runAction() is used on the avatar which is equivalent to clearing any actions in its queue and adding the new action. This way, wherever you click, the avatar will immediately begin walking to that point rather than waiting to finish any other walk actions.
Now run the script and click anywhere on the ground and the avatar will walk to that point.
For additional examples, check out: