Advertisement
Guest User

blender-fall-off-world-collision

a guest
Sep 2nd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. import bge
  2. import mathutils
  3. import aud
  4. import time
  5. import mytools
  6. import statePlayer
  7.  
  8. device = aud.device()
  9. sndPlrLossLife = aud.Factory.file(
  10.                 bge.logic.expandPath("//assets/music/smw_lost_a_life.wav"))
  11.                              
  12. p = bge.constraints.getCharacter('player_avatar')
  13. cont = bge.logic.getCurrentController()
  14. obj = cont.owner
  15.  
  16. scene = bge.logic.getCurrentScene()
  17.  
  18. marker = str(scene.objects['player_avatar']['spawnMarker'])
  19. respawn_marker = scene.objects[marker]
  20.  
  21. detector_camera_pan = scene.objects['detector_camera_pan']
  22. detector_camera_pan_left= scene.objects['detector_camera_pan_left']
  23.  
  24. game_scene = mytools.getScene(bge.logic.getSceneList(), 'game_world_level_1')
  25.  
  26. if obj.worldPosition.z < -15:
  27.     print('player fell of the world, respawning')
  28.    
  29.     obj.worldPosition = respawn_marker.worldPosition
  30.    
  31.     sndPlrLossLife = sndPlrLossLife.pitch(1)
  32.     device.play(sndPlrLossLife)
  33.    
  34.     detector_camera_pan.worldPosition = obj.worldPosition
  35.     detector_camera_pan_left.worldPosition = obj.worldPosition
  36.        
  37.     game_scene.objects['player_avatar']['health']-= 1
  38.     statePlayer.collideWithEnemy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement