mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
added SwimWalker; strafe turns
This commit is contained in:
parent
830d509665
commit
81edb9fc7d
@ -184,14 +184,7 @@ class NonPhysicsWalker(DirectObject.DirectObject):
|
||||
"""
|
||||
onScreenDebug.add("controls", "NonPhysicsWalker")
|
||||
|
||||
def handleAvatarControls(self, task):
|
||||
"""
|
||||
Check on the arrow keys and update the avatar.
|
||||
"""
|
||||
if not self.lifter.hasContact():
|
||||
# hack fix for falling through the floor:
|
||||
messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
|
||||
|
||||
def _calcSpeeds(self):
|
||||
# get the button states:
|
||||
forward = inputState.isSet("forward")
|
||||
reverse = inputState.isSet("reverse")
|
||||
@ -209,7 +202,17 @@ class NonPhysicsWalker(DirectObject.DirectObject):
|
||||
self.rotationSpeed=not slide and (
|
||||
(turnLeft and self.avatarControlRotateSpeed) or
|
||||
(turnRight and -self.avatarControlRotateSpeed))
|
||||
|
||||
|
||||
def handleAvatarControls(self, task):
|
||||
"""
|
||||
Check on the arrow keys and update the avatar.
|
||||
"""
|
||||
if not self.lifter.hasContact():
|
||||
# hack fix for falling through the floor:
|
||||
messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
|
||||
|
||||
self._calcSpeeds()
|
||||
|
||||
if __debug__:
|
||||
debugRunning = inputState.isSet("debugRunning")
|
||||
if debugRunning:
|
||||
|
20
direct/src/controls/SwimWalker.py
Executable file
20
direct/src/controls/SwimWalker.py
Executable file
@ -0,0 +1,20 @@
|
||||
from direct.showbase.ShowBaseGlobal import *
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.controls import NonPhysicsWalker
|
||||
|
||||
class SwimWalker(NonPhysicsWalker.NonPhysicsWalker):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("SwimWalker")
|
||||
|
||||
def _calcSpeeds(self):
|
||||
# get the button states:
|
||||
forward = inputState.isSet("forward")
|
||||
reverse = inputState.isSet("reverse")
|
||||
turnLeft = inputState.isSet("turnLeft") or inputState.isSet("slideLeft")
|
||||
turnRight = inputState.isSet("turnRight") or inputState.isSet("slideRight")
|
||||
# Determine what the speeds are based on the buttons:
|
||||
self.speed=(forward and self.avatarControlForwardSpeed or
|
||||
reverse and -self.avatarControlReverseSpeed)
|
||||
self.slideSpeed=0.
|
||||
self.rotationSpeed=(
|
||||
(turnLeft and self.avatarControlRotateSpeed) or
|
||||
(turnRight and -self.avatarControlRotateSpeed))
|
Loading…
x
Reference in New Issue
Block a user