mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-19 05:06:25 -04:00
if no target, revert to gravity walker controls
This commit is contained in:
parent
598970b97d
commit
fac3dc50d2
@ -5,11 +5,6 @@ import GravityWalker
|
|||||||
class BattleWalker(GravityWalker.GravityWalker):
|
class BattleWalker(GravityWalker.GravityWalker):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
GravityWalker.GravityWalker.__init__(self)
|
GravityWalker.GravityWalker.__init__(self)
|
||||||
self.targetNp = None
|
|
||||||
|
|
||||||
def setTarget(self, nodepath):
|
|
||||||
# Set target that movement will be relative to
|
|
||||||
self.targetNp = nodepath
|
|
||||||
|
|
||||||
def getSpeeds(self):
|
def getSpeeds(self):
|
||||||
#assert(self.debugPrint("getSpeeds()"))
|
#assert(self.debugPrint("getSpeeds()"))
|
||||||
@ -20,6 +15,15 @@ class BattleWalker(GravityWalker.GravityWalker):
|
|||||||
"""
|
"""
|
||||||
Check on the arrow keys and update the avatar.
|
Check on the arrow keys and update the avatar.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# If targetNp is not available, revert back to GravityWalker.handleAvatarControls.
|
||||||
|
# This situation occurs when the target dies, but we aren't switched out of
|
||||||
|
# battle walker control mode.
|
||||||
|
|
||||||
|
targetNp = self.avatarNodePath.currentTarget
|
||||||
|
if targetNp == None or targetNp.isEmpty():
|
||||||
|
return GravityWalker.GravityWalker.handleAvatarControls(self, task)
|
||||||
|
|
||||||
# get the button states:
|
# get the button states:
|
||||||
run = inputState.isSet("run")
|
run = inputState.isSet("run")
|
||||||
forward = inputState.isSet("forward")
|
forward = inputState.isSet("forward")
|
||||||
@ -84,7 +88,7 @@ class BattleWalker(GravityWalker.GravityWalker):
|
|||||||
|
|
||||||
# Before we do anything with position or orientation, make the avatar
|
# Before we do anything with position or orientation, make the avatar
|
||||||
# face it's target
|
# face it's target
|
||||||
self.avatarNodePath.headsUp(self.targetNp)
|
self.avatarNodePath.headsUp(targetNp)
|
||||||
|
|
||||||
# Check to see if we're moving at all:
|
# Check to see if we're moving at all:
|
||||||
self.moving = self.speed or self.slideSpeed or self.rotationSpeed or (self.priorParent!=Vec3.zero())
|
self.moving = self.speed or self.slideSpeed or self.rotationSpeed or (self.priorParent!=Vec3.zero())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user