Is there a function available to the Actor class that can allow me to animate it by percentage?
Say for instance, i have an animation called “Walk”. Half way (that’ll be 50%) through that animation pose of the model is the left leg is raised forward while the right leg is on the ground. And if I use that function, something like:
…the pose would be the one i described.
Does a function/method like this exist? I’m looking for something like this so I would have complete control over what pose gets displayed every game loop.
Thanks in advance…
welcome to panda 3d.
i guess what you’r looking for is called “blending” of animations.it is supported by panda. see the manual section about it: https://www.panda3d.org/manual/index.php/Actor_Animations#Blending
have a nice day,
ps sorry for the very short reply but i am in a hurry right now
It’s not exactly as how you described it but you can use the AnimControl class (described in Actor Animations) to do what you need.
def __init__(self, actor, anim):
self.animControl = actor.getAnimContrl(anim)
# Fake subclassing, taking all the attributes of AnimControl
# Not necessary but nice and convenient
for attr in dir(self.animControl):
if attr != 'pose':
setattr(self, attr, getattr(self.animContrl, attr))
self.total_frames = self.getNumFrames()
def pose(self, pose_value):
if type(pose_value) is float:
# Value clamping, so values > 0.0, < 1.0
pose_value = min(1.0, pose_value)
pose_value = max(0.0, pose_value)
So to use it:
walkControl = PercentAnimControl(actor_instance, 'walk')
Thanks a lot Thomas and ZeroByte. And apologies for the late reply. I sorta had problems accessing the forums the yesterday.
I’ll try your suggestions now. I will get back here and post another reply if it works.