Greetings! I am new to Panda3d and Python, so I apologize if I sound all over the place. I’m not even sure if I’m posting in the right topic, but I’ll hope for the best because this sounded like the place to post my issue! Now that I got that out of the way…
I was having trouble with animating my character whenever he/she tries to walk/turn. The animation simply doesn’t play but the character gets into their position like they are trying to do the animation. I’m using a key map to help my character move. Here’s the code for method that plays the animation:
# dt here represents delta time
def move(self, dt):
if (not self.keyMap["w"] and not self.keyMap["s"] and not self.keyMap["a"] and not self.keyMap["d"]):
self.body.play('neutral');
else:
if(self.keyMap["a"]):
self.body.stop();
self.body.setH(self.body, dt * 90);
self.body.play('turnL');
if (self.keyMap["d"]):
self.body.stop();
self.body.setH(self.body, dt * -90);
self.body.play('turnR');
if (self.keyMap["w"]):
self.body.stop();
self.body.setY(self.body, dt * 10);
self.body.play('run');
if (self.keyMap["s"]):
self.body.stop();
self.body.setY(self.body, dt * -10);
self.body.play('run');
Here is also the key map that I use:
def setKeyMaps(self):
self.keyMap = {"w": False,
"s": False,
"a": False,
"d": False};
# If key is pressed, set to true
self.accept("w", self.setKey, ["w", True]);
self.accept("s", self.setKey, ["s", True]);
self.accept("a", self.setKey, ["a", True]);
self.accept("d", self.setKey, ["d", True]);
# If key isn't pressed anymore, set to false
self.accept("w-up", self.setKey, ["w", False]);
self.accept("s-up", self.setKey, ["s", False]);
self.accept("a-up", self.setKey, ["a", False]);
self.accept("d-up", self.setKey, ["d", False]);
The only other place I do anything with the animation is when I “load” it into my ‘body’ instance of the Actor class.
Edit: In addition, when I don’t have any input from the keys (I don’t have the code for the keys at all,) and I load in the animations one by one to test, the animations work perfectly fine by themselves.
Any thoughts on this matter would be appreciated.