如何在panda3d中间隔后停止动画?

时间:2016-10-19 14:43:26

标签: python panda3d

以下代码不符合我的期望。如果用户按下“w”键,我希望它向北走。演员,熊猫确实第一次显示动作没有完成动画,它停止并且再也不会移动。我错误地使用了发动机吗?或者我应该用别的东西来实现我的目的吗?

from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
from panda3d.core import Point3
from direct.interval.IntervalGlobal import*
class Window(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
    def loadModels(self):
        self.envir = loader.loadModel("models/environment")
        self.envir.reparentTo(self.render)
        self.envir.setY(1183.37)
        self.envir.setHpr(0, 8, 0)
        self.panda = Actor("models/panda-model", {"idle": "models/panda-model", "walk": "models/panda-walk4"})
        self.pandaPosY = 502
        self.pandaPosX = 0
        self.pandaPosZ = -102.66
        self.panda.setScale(0.05, 0.05, 0.05)
        self.panda.setY(502)
        self.panda.setZ(-102.66)
        self.panda.setHpr(180, 0, 0)
        self.accept("w", self.MoveForward)
        self.panda.reparentTo(self.render)
    def MoveForward(self):
        pandaForwardWalk = self.panda.posInterval(2, Point3(self.pandaPosX, self.pandaPosY + 50, self.pandaPosZ), startPos = Point3(self.pandaPosX, self.pandaPosY, self.pandaPosZ))
        self.panda.play("walk")
        self.pandaForwardWalk = Sequence(pandaForwardWalk, name="pandaForwardWalk")
game = Window()
game.loadModels()
game.run()

1 个答案:

答案 0 :(得分:2)

要连续循环动画,请使用.loop()而不是.play()。要实际移动模型,请使用.set_pos()或查找LerpIntervals:https://www.panda3d.org/manual/index.php/Lerp_Intervals