2

下面的代码不符合我的期望。如果用户按下“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()
4

1 回答 1

2

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

于 2016-10-23T13:49:55.487 回答