478
478
scale = self.max_shadow_scale
479
479
self.shadow.setScale(scale)
481
def doJump(self, forwardSpeed, extraSpeedVec=Vec3()):
481
def doJump(self, forwardSpeed, jump_direction=Vec3(0,0,0), extraSpeedVec=Vec3()):
482
482
"""This will let the actor node jump forward on the local y-axis
483
483
with the upward speed given in jumpForce and forward given in speed.
484
484
Note, if the actorNode shouldn't slide after landing call the
485
485
physics.land function with the same actorNode"""
486
486
# as we leave the ground set the active platform, if any, to None
487
490
self.active_platform = None
489
#jumpVec = Vec3(0, -forwardSpeed/self.current_max_accleration*self.jump_forward_force_mult, 1)
490
jumpVec = Vec3(0, -forwardSpeed/self.current_max_accleration*self.jump_forward_force_mult, 0.2)
491
jumpVec = Vec3(0, -forwardSpeed/self.current_max_accleration*self.jump_forward_force_mult, 1)
491
492
jumpVec *= self.jump_strength
493
494
# rotate the extraSpeedVector to face the same direction the mainNode vector
498
499
jumpVec += rotatedExtraSpeedVec
499
500
self.actorNode.getPhysicsObject().addLocalImpulse(jumpVec)
505
self.active_platform = None
507
dt = globalClock.getDt()
509
0,#jump_direction.getX()*dt,
510
-((forwardSpeed*self.jump_forward_force_mult))*dt,
511
(self.phys_jump_strength+jump_direction.getZ())*dt)
512
jumpVec *= self.jump_strength
514
# rotate the extraSpeedVector to face the same direction the mainNode vector
515
charVec = self.mainNode.getRelativeVector(render, extraSpeedVec)
517
rotatedExtraSpeedVec = charVec * extraSpeedVec.length()
519
jumpVec += rotatedExtraSpeedVec*dt
521
self.actorNode.getPhysicsObject().addLocalImpulse(jumpVec)
523
vel = self.actorNode.getPhysicsObject().getVelocity()
528
# Make sure we don't jump/move faster than we are alowed to
529
#if abs(velX) > self.max_jump_force_internal_X \
530
#or abs(velY) > self.max_jump_force_internal_Y:
531
# # we need to make sure X and Y are at the same distance
532
# # as before otherwise jump direction will be shifted
533
# if abs(velX) > abs(velY):
535
# #TODO: Calculate diff between x and y and subtract/add to respective other
537
# velX = -self.max_jump_force_internal_X
539
# velX = self.max_jump_force_internal_X
540
#if abs(velY) > self.max_jump_force_internal_Y:
542
# velY = -self.max_jump_force_internal_Y
544
# velY = self.max_jump_force_internal_Y
545
if abs(velZ) > self.max_jump_force_internal_Z:
547
velZ = -self.max_jump_force_internal_Z
549
velZ = self.max_jump_force_internal_Z
551
self.actorNode.getPhysicsObject().setVelocity(velX, velY, velZ)
502
554
self.actorNode.getPhysicsObject().setVelocity(0,0,0)