mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -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")
|
onScreenDebug.add("controls", "NonPhysicsWalker")
|
||||||
|
|
||||||
def handleAvatarControls(self, task):
|
def _calcSpeeds(self):
|
||||||
"""
|
|
||||||
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])
|
|
||||||
|
|
||||||
# get the button states:
|
# get the button states:
|
||||||
forward = inputState.isSet("forward")
|
forward = inputState.isSet("forward")
|
||||||
reverse = inputState.isSet("reverse")
|
reverse = inputState.isSet("reverse")
|
||||||
@ -210,6 +203,16 @@ class NonPhysicsWalker(DirectObject.DirectObject):
|
|||||||
(turnLeft and self.avatarControlRotateSpeed) or
|
(turnLeft and self.avatarControlRotateSpeed) or
|
||||||
(turnRight and -self.avatarControlRotateSpeed))
|
(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__:
|
if __debug__:
|
||||||
debugRunning = inputState.isSet("debugRunning")
|
debugRunning = inputState.isSet("debugRunning")
|
||||||
if 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