Hi guys,
I want to load an actor, play through its animation once and as soon as it is finished, I want the actor to stay in the last frame.
Currently it plays through the animation and then loops back to the first frame.
Any ideas how to do it?
Hi guys,
I want to load an actor, play through its animation once and as soon as it is finished, I want the actor to stay in the last frame.
Currently it plays through the animation and then loops back to the first frame.
Any ideas how to do it?
for what I got in your question, looks like you’re missing to read this section of the panda3D manual: panda3d.org/manual/index.php/Actor_Animations
well… not really.
I am using actor interval. Here is my code :
xx = random.randint(-3000,200)
yy = random.randint(1500, 3000)
stones = Actor("stones",{"stones_anim":"stones_anim"})
stones.setTwoSided(True)
stones.reparentTo(render)
stones.setPos(xx,yy,0)
stones.setScale(5)
stones.actorInterval("stones_anim", playRate = 1 ).start()
The problem is, after the animation finishes, it loops back to frame one. Imagine this being a glass, the animation is of the glass breaking… and then as soon as the animation is finished, the glass is back to its original form.
Thanks!
ok now it is more clear - you missed to read this page perhaps:
panda3d.org/manual/index.php/Actor_Intervals
yeah, I cant really find anything that helps me there.
I can set loop = 0, but it keeps doing the same thing. Also endFrame just stops the animation earlier but still loops back.
I realise that is ideal for animation cycles, but this is not one.
Anyone any ideas? I know there must be a really simple solution which i am missing…
ok I just wanted to be sure of that.
Now, try this piece of code and tellme if behaves as you wish:
""" PRESS 'p' TO PLAY THE ANIMATION ONCE
"""
from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
#=========================================================================
#
class mysnip(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.cam.setPos(0, -10, 4)
self.pandaActor = Actor(
"models/panda", {"walk": "models/panda-walk"}
)
self.pandaActor.setScale(0.2, 0.2, 0.2)
self.pandaActor.reparentTo(render)
self.pandaActor.pose("walk", 1)
#**
self.accept(
'p', lambda: self.pandaActor.actorInterval("walk", playRate = 1).start()
)
self.cam.lookAt(self.pandaActor)
#=========================================================================
#
if __name__ == "__main__":
snip=mysnip()
snip.run()
If it works correctly probably the issue is on your egg animation that is exported not as you expected.
hmmm… when I use ur script with my files, it works as expected.
So it’s not my maya export.
This works perfectly.
""" PRESS 'p' TO PLAY THE ANIMATION ONCE
"""
from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
import random
#=========================================================================
#
class mysnip(ShowBase):
def __init__(self):
ShowBase.__init__(self)
xx = random.randint(-3,2)
yy = random.randint(3, 10)
stones = Actor("stones",{"stones_anim":"stones_anim"})
stones.setTwoSided(True)
stones.reparentTo(render)
stones.setPos(xx,yy,0)
stones.setScale(5)
self.accept(
'p', lambda: stones.actorInterval("stones_anim", playRate = 1).start() )
#=========================================================================
#
if __name__ == "__main__":
snip=mysnip()
snip.run()
well that is quite weird because it is almost the same as your former code. Can’t find an explanation of this but happy to see you overcome the issue.
Well, cant really understand this either. I re-exported from maya using the Both option, instead of a separate actor and a separate animation, and now it works with my original code.
Anyway, thanks for all your help astelix.