Actor Problems with V. 1.0.5, Please Answer

Hello, newbie to these forums here with an irritating problem, and I will point out that my python file is downloaded fromthis link:

freewebs.com/shall56/dragonfly.zip

The libraries I have in that file include: ClassGlobals.py (where I load all my meshes), environment.py, start.py (start screen), dragonMain.py (main files), followingCam.py, level1.py(where the environment models load), loadMusic.py, Pyro.py (the Actor file that I am struggling to make a Class), and soundFX.py.

My troubles lie in wiring the key controls to the Main file in order to get my Actor in Pyro.py to walk. The character is able to load into my main, but so far I have tried writing a key controls library with little to no success. It’s not that I don’t know how to make key controls coupled with character animation, it’s just that I don’t how to put them into a separate library to insert into my Main file.

If I can get any help with making a library or any kinds of clues, that would be of help. Hopefully this update of my post is more specific than the last, and be sure to download my file that I have posted up in the first paragraph. Thanks in advance!!

I’m sorry; I’m having a hard time understanding your description of the problem. I also don’t see anything in the posted code snippet that seems to have anything to do with loading an Actor or playing animation on it.

I also don’t know what you mean by Pyro.py–is that one of your files in the linked zip file?

Maybe if you started working out a simpler problem, for instance, coding any response at all to a keypress (for instance, you could make it toggle wireframe in response to a key, or exit the application, or something). If you get that working, then you have demonstrated that you understand how to respond to keypresses.

The next step is to figure out how to load an animation and play it. Try to write a simple program that loads an actor and plays its animation, without any keyboard input at all. If you get that working, then you have demonstrated that you understand how to play animations on an Actor.

Once you have written both of those simple applications, it should be a simple logical step to write an application that plays an animation in response to a keypress.

And once you have gotten that application working, it should be much easier to solve the problem that you are trying to solve now. :slight_smile:

David

I was getting an error while trying to download the zip file, so I am not exactly sure what you want.

My best guess is that you would want to store your key controls in a python dictionary in such a way that you can bind the certain keys to certain animations of your actor. For example:


controlsDict = {'w': 'wave',
                'd': 'dance'}

where ‘wave’ and ‘dance’ are the animation names set up when the actor was loaded. You then set up a bindControl function that walks through the dictionary and tells the actor to play the animation when that key is pressed. A simple example would be:

#defined inside a DirectObject class
def bindControls(self, cDict):
    for k in cDict.keys():
        self.ignore(k)
        animName = cDict[k]
        self.accept(k, self.myReferenceToActor.play(animName))

You may have a different way of binding animations to keys (some more advanced methods have been discussed in the forums)