shuvit 5 years ago
parent
commit
bd46cd1839
1 changed files with 48 additions and 36 deletions
  1. 48
    36
      scripts/camera.py

+ 48
- 36
scripts/camera.py View File

@@ -3,9 +3,11 @@ import bge
3 3
 import mathutils
4 4
 from mathutils import *
5 5
 scene = bge.logic.getCurrentScene()
6
+import camFSM
6 7
 #cont = bge.logic.getCurrentController()
7 8
 #own = cont.owner
8 9
 def main(cont):
10
+    #camFSM.main(cont)
9 11
     own = cont.owner
10 12
     dict = bge.logic.globalDict 
11 13
     camempty = scene.objects['camEmpty.001']
@@ -75,24 +77,25 @@ def main(cont):
75 77
         if down.triggered == True and LAST_GRIND == False and walk == 0:
76 78
             hitPosition = down.hitPosition
77 79
             distance = own.getDistanceTo(hitPosition)
78
-            cam_moved = 1       
79
-            if distance < .2:
80
-                camempty['hitdown'] = True
81
-                cam.height = cam_height + .3
82
-                cam.damping = .0 
83
-                #print("raise cam")
84
-            if zdist < -.2:
85
-                cam.height = lastCamheight + .01
86
-                cam.damping = .0
87
-                raised = 1    
88
-            if (distance > .4 and distance < .6) and zdist > -.2 and raised == 0:
89
-                camheight2 = cam.height - .001
90
-                if cam.height < .2: 
91
-                    cam.height = camheight2
92
-                    #print("slow lower")
93
-            if distance >= .6 and zdist > -.2 and raised == 0:
94
-                cam.height = cam.height - .02
95
-                #print("slow lower2")           
80
+            cam_moved = 1  
81
+            if 'vert' not in down.hitObject:     
82
+                if distance < .2:
83
+                    camempty['hitdown'] = True
84
+                    cam.height = cam_height + .3
85
+                    cam.damping = .0 
86
+                    print("raise cam")
87
+                if zdist < -.2:
88
+                    cam.height = lastCamheight + .01
89
+                    cam.damping = .0
90
+                    raised = 1    
91
+                if (distance > .4 and distance < .6) and zdist > -.2 and raised == 0:
92
+                    camheight2 = cam.height - .001
93
+                    if cam.height < .2: 
94
+                        cam.height = camheight2
95
+                        #print("slow lower")
96
+                if distance >= .6 and zdist > -.2 and raised == 0:
97
+                    cam.height = cam.height - .02
98
+                    #print("slow lower2")           
96 99
         if down.triggered == False and LAST_GRIND == False and cam_moved == 0 and walk == 0:
97 100
             camempty['hitdown'] = False
98 101
             if cam_height > (cam_def_height + .06) and zdist > -.2 and raised == 0:
@@ -123,6 +126,7 @@ def main(cont):
123 126
                 cam.min = cam.min + .1
124 127
                 cam.max = cam.max + .1
125 128
             cam.height = cam_height + .01
129
+            print('moving cam up')
126 130
             cam.damping = .001
127 131
             cont.activate(move)
128 132
             
@@ -160,18 +164,19 @@ def main(cont):
160 164
         control = "control_cube.002"
161 165
         hitobj = hit[0]
162 166
         hitobj = str(hitobj)
163
-        if hitobj != control and walk == 0:
164
-            
165
-            cam.damping = .0 
166
-            if cam.height < 2:
167
-                cam.height = cam_height + .1
168
-                cam.max = cam.max - .2
169
-                #print('small move')
170
-            elif cam.height >= 2 and cam.height < 4:
171
-                cam.height = cam_height + .05
172
-                cam.max = cam.max - .05                
173
-                #print('big move')
174
-    
167
+        if hit[0]:
168
+            if hitobj != control and walk == 0 and 'vert' not in hit[0] and 'ground' in hit[0] and controlcube['ragdoll_active'] == False:
169
+                
170
+                cam.damping = .0 
171
+                if cam.height < 2:
172
+                    cam.height = cam_height + .1
173
+                    cam.max = cam.max - .2
174
+                    print('small move')
175
+                elif cam.height >= 2 and cam.height < 4:
176
+                    cam.height = cam_height + .05
177
+                    cam.max = cam.max - .05                
178
+                    print('big move')
179
+        
175 180
     if dict['menu_idle_timer'] > 300:
176 181
         move_len = 2048
177 182
         if own['idlecampos_x'] < move_len:
@@ -270,7 +275,7 @@ def main(cont):
270 275
 ################    
271 276
     #print(dict['walk'], 'walk')
272 277
     multer = .02
273
-    if dict['walk'] == 1:
278
+    if dict['walk'] == 1 and controlcube['ragdoll_active'] == False:
274 279
         if dict['cur_ccH_targetHeight'] < dict['cam_walk_height']:
275 280
             dist = dict['cam_walk_height'] - dict['cur_ccH_targetHeight']
276 281
             
@@ -317,11 +322,18 @@ def main(cont):
317 322
         num = ccH_targetHeight - ccheight
318 323
     else:
319 324
         own['camHeightSet'] = True    
320
-           
321
-    if dict['npause'] == False:
322
-        cont.activate(own.actuators['Camera']) 
323
-        controlcube['camera'] = 0    
324
-    
325
+    try:       
326
+        if dict['npause'] == False and controlcube['ragdoll_active'] == False:
327
+            cont.activate(own.actuators['Camera']) 
328
+            controlcube['camera'] = 0    
329
+        if controlcube['ragdoll_active'] == True:
330
+            #print('ragdoll_camera', own.actuators['Camera'].object)
331
+            own.actuators['Camera'].object = scene.objects['ragdoll_parent']
332
+            cont.activate(own.actuators['Camera']) 
333
+            controlcube['camera'] = 0
334
+    except:
335
+        pass
336
+
325 337
     cur_lens = cam1.lens
326 338
     cur_min = cam.min
327 339
     cur_max = cam.max

Loading…
Cancel
Save