如何在 panda3d 的间隔后停止动画?
How to stop an animation after an interval in 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()
要连续循环播放动画,请使用 .loop() 而不是 .play()。要实际移动模型,请使用 .set_pos(),或查找 LerpIntervals:https://www.panda3d.org/manual/index.php/Lerp_Intervals
下面的代码不符合我的预期。如果用户按下 "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()
要连续循环播放动画,请使用 .loop() 而不是 .play()。要实际移动模型,请使用 .set_pos(),或查找 LerpIntervals:https://www.panda3d.org/manual/index.php/Lerp_Intervals