PDA

View Full Version : Avatar


Moh200jo
02-16-2009, 10:54 AM
Hi all,
I am beginner on vizard, I am trying to build avatar walking with different speeds (I will control this speed by keyboard), this avatar should hit balls or whatever on his way by knife carrying by him
Could you please any one help me how can I do this?:confused:
Thanks

DrunkenBrit
02-17-2009, 12:46 AM
Try the tutorials inside of Vizard (Help->Tutorials). There's a whole section on avatars, it's a good starting point.

Moh200jo
02-17-2009, 01:39 AM
Many thanks for your reply. I have read all the examples at teacher book, and I have done well at most cases. What I am doing now? I am trying to control the avatar walking through the keyboard (for example when I press + the speed increase and when I press – the speed decline and so on) as well as I want when I press space the arm of the avatar hit the balloons.
Am I wondering for the last points (arm and hit the balloon)?
Please any help.
thanks

DrunkenBrit
02-17-2009, 01:53 AM
Do you have the avatar walking around? If so you'll need a keyboard callback function to control the speed, something like:



# Load avatar
myAvatar = viz.add('avatar.cfg')

# Speed of avatar
avSpeed = 1.0

def myKeyboard(key):
global avSpeed

# Increase speed on key press
if key == '+':
avSpeed = avSpeed + 0.5
myAvatar.speed(avSpeed)

# Decrease speed on key press
if key == '-':
avSpeed = avSpeed - 0.5
myAvatar.speed(avSpeed)

# Assign callback function to keyboard event
viz.callback(viz.KEYBOARD_EVENT,myKeyboard)



I think you'll need something like the above anyway. Hope it helps.

As for the arm hitting the baloons, sorry i'm not fully understanding what you're meaning.

Moh200jo
02-17-2009, 02:13 AM
First of all many thanks for your help that is fabulous. I tried to let the avatar to hit the balloon while he is walking by the knife link with his hand. What I cant to do -although I did it in many examples- to move his arm with the knife (around 40 degree) to hit the balloon.
thanks,

DrunkenBrit
02-17-2009, 02:48 AM
If you want the arm to move wouldn't that be done by an animation of his arm moving 40 degrees?

Moh200jo
02-17-2009, 03:13 AM
So, how can I let him hit the balloon by his hand?

DrunkenBrit
02-17-2009, 03:26 AM
Well, at a guess, you could always just hardcode it and position the balloon near the path the avatar moves along and when it gets to the position the balloon is in the world run the animation that moves his arm as if to strike the balloon.

If you've got variable moving speeds in there, i'd probably attempt to check the distance between the avatar and the balloon, once the avatar reaches a certain distance from balloon you could trigger the animation once to swing his arm (change the "trigger animation distance" between the avatar and balloon until you get it right).

I haven't worked with avatars before in depth, only through the tutorials so if there's a better/easier way someone else would have to jump in and assist you. Like I said, this is at a guess :)

Moh200jo
02-17-2009, 04:51 AM
The arm moving is done  but to hit the balloon I could not understood this concept from the examples (any body can help me how this is working)?

DrunkenBrit
02-17-2009, 04:58 AM
Like i've said in the above post, simulate a collision based on events i.e your conditions could be:

IF armMoving == True AND distanceBetweenArmAndBalloon < strikeDistance
balloonCollision = True

Something like this would be checked maybe each 0.05 seconds in a timer callback function. Then take whatever action you need when the balloon is struck.

Moh200jo
02-17-2009, 05:03 AM
my question about the ballooncollision; how?

DrunkenBrit
02-17-2009, 05:12 AM
Sorry, i've done my best to try and explain how i would initially go about it based on what I think you're after achieving and without seeing your code so far and the current world you've created.

Moh200jo
02-17-2009, 06:36 AM
I appreciate your efforts with me. I am just trying to understand some concepts before to go in my world. However, I will email you the world that I am playing with now.
Thanks,