mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
added toggle strafe controls
This commit is contained in:
parent
7cc8f52e5e
commit
69fdd9b8a3
@ -2,6 +2,12 @@
|
||||
from direct.showbase.ShowBaseGlobal import *
|
||||
import GravityWalker
|
||||
|
||||
BattleStrafe = 0
|
||||
|
||||
def ToggleStrafe():
|
||||
global BattleStrafe
|
||||
BattleStrafe = not BattleStrafe
|
||||
|
||||
class BattleWalker(GravityWalker.GravityWalker):
|
||||
def __init__(self):
|
||||
GravityWalker.GravityWalker.__init__(self)
|
||||
@ -21,7 +27,7 @@ class BattleWalker(GravityWalker.GravityWalker):
|
||||
# battle walker control mode.
|
||||
|
||||
targetNp = self.avatarNodePath.currentTarget
|
||||
if targetNp == None or targetNp.isEmpty():
|
||||
if not BattleStrafe or targetNp == None or targetNp.isEmpty():
|
||||
return GravityWalker.GravityWalker.handleAvatarControls(self, task)
|
||||
|
||||
# get the button states:
|
||||
@ -97,6 +103,12 @@ class BattleWalker(GravityWalker.GravityWalker):
|
||||
slideDistance = dt * self.slideSpeed
|
||||
rotation = dt * self.rotationSpeed
|
||||
|
||||
# Prevent avatar from getting too close to target
|
||||
d = self.avatarNodePath.getPos(targetNp)
|
||||
if (d[0]*d[0]+d[1]*d[1] < .1):
|
||||
print "toooo close"
|
||||
distance = 0
|
||||
|
||||
# Take a step in the direction of our previous heading.
|
||||
self.vel=Vec3(Vec3.forward() * distance +
|
||||
Vec3.right() * slideDistance)
|
||||
|
Loading…
x
Reference in New Issue
Block a user