mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fix for strafe
This commit is contained in:
parent
0fc3e0fdcc
commit
fdf8a79fea
@ -515,9 +515,7 @@ class GravityWalker(DirectObject.DirectObject):
|
|||||||
rotation = dt * self.rotationSpeed
|
rotation = dt * self.rotationSpeed
|
||||||
|
|
||||||
# Take a step in the direction of our previous heading.
|
# Take a step in the direction of our previous heading.
|
||||||
self.vel=Vec3(Vec3.forward() * distance +
|
if distance or slideDistance or self.priorParent != Vec3.zero():
|
||||||
Vec3.right() * slideDistance)
|
|
||||||
if self.vel != Vec3.zero() or self.priorParent != Vec3.zero():
|
|
||||||
# rotMat is the rotation matrix corresponding to
|
# rotMat is the rotation matrix corresponding to
|
||||||
# our previous heading.
|
# our previous heading.
|
||||||
rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
|
rotMat=Mat3.rotateMatNormaxis(self.avatarNodePath.getH(), Vec3.up())
|
||||||
@ -526,24 +524,23 @@ class GravityWalker(DirectObject.DirectObject):
|
|||||||
else:
|
else:
|
||||||
contact = self.lifter.getContactNormal()
|
contact = self.lifter.getContactNormal()
|
||||||
forward = contact.cross(Vec3.right())
|
forward = contact.cross(Vec3.right())
|
||||||
forward = Vec3(rotMat.xform(forward))
|
# Consider commenting out this normalize. If you do so
|
||||||
# Consider commenting out this normalize. If you do so
|
# then going up and down slops is a touch slower and
|
||||||
# then going up and down slops is a touch slower and
|
# steeper terrain can cut the movement in half. Without
|
||||||
# steeper terrain can cut the movement in half. Without
|
# the normalize the movement is slowed by the cosine of
|
||||||
# the normalize the movement is slowed by the cosine of
|
# the slope (i.e. it is multiplied by the sign as a
|
||||||
# the slope (i.e. it is multiplied by the sign as a
|
# side effect of the cross product above).
|
||||||
# side effect of the cross product above).
|
forward.normalize()
|
||||||
forward.normalize()
|
|
||||||
self.vel=Vec3(forward * distance)
|
self.vel=Vec3(forward * distance)
|
||||||
if slideDistance:
|
if slideDistance:
|
||||||
if self.isAirborne:
|
if self.isAirborne:
|
||||||
right = Vec3.right()
|
right = Vec3.right()
|
||||||
else:
|
else:
|
||||||
right = forward.cross(contact)
|
right = forward.cross(contact)
|
||||||
right = Vec3(rotMat.xform(right))
|
# See note above for forward.normalize()
|
||||||
# See note above for forward.normalize()
|
right.normalize()
|
||||||
right.normalize()
|
self.vel=Vec3(self.vel + (right * slideDistance))
|
||||||
self.vel=Vec3(self.vel + right * slideDistance)
|
self.vel=Vec3(rotMat.xform(self.vel))
|
||||||
step=self.vel + (self.priorParent * dt)
|
step=self.vel + (self.priorParent * dt)
|
||||||
self.avatarNodePath.setFluidPos(Point3(
|
self.avatarNodePath.setFluidPos(Point3(
|
||||||
self.avatarNodePath.getPos()+step))
|
self.avatarNodePath.getPos()+step))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user