Browse Source

grind fixes

shuvit 5 years ago
parent
commit
79e6fca2a5
5 changed files with 63 additions and 39 deletions
  1. 9
    1
      Manager.py
  2. 4
    2
      controller2.py
  3. 42
    33
      grindV2.py
  4. 2
    1
      scene_init.py
  5. 6
    2
      walk.py

+ 9
- 1
Manager.py View File

@@ -353,11 +353,19 @@ def main():
353 353
             camspeed2 = .1 #.055
354 354
             camrot1 = .02 #.005
355 355
             camrot2 = .04 #.02
356
+#            perc = (lUD * 100 * (10 / 80)) *2
357
+#            perc = round(perc,2)
358
+#            print(perc)
359
+#            perc = .025 * perc
360
+#            newUD = (lUD * .1) * 5
361
+#            if lUD > .0005 or lUD < -.0005:
362
+#                camspeed1 = abs(perc)
363
+#                camspeed2 = abs(perc)
356 364
             #up
357 365
             if lUD < -0.080:
358 366
                 followcam.actuators["up"].dLoc = [ 0, 0, -camspeed2]
359 367
                 cont.activate(followcam.actuators["up"])
360
-                #print("fastup")
368
+                print("fastup")
361 369
             else:
362 370
                 cont.deactivate(followcam.actuators["up"])    
363 371
     #            #down    

+ 4
- 2
controller2.py View File

@@ -2205,8 +2205,10 @@ def main():
2205 2205
                 own['airup'] = 1
2206 2206
             if pos > own['last_posz']:
2207 2207
                 own["air_height"] = pos  
2208
-            own['last_posz'] = pos
2209
-            
2208
+            own['last_posz'] = pos   
2209
+        else:
2210
+            own['airup'] = 0  
2211
+              
2210 2212
     def onramp():
2211 2213
         if r_ground.positive:
2212 2214
             if 'ramp' in r_ground.hitObject:

+ 42
- 33
grindV2.py View File

@@ -116,7 +116,9 @@ def main():
116 116
          velx = linVelocity2.x
117 117
          vely = linVelocity2.y     
118 118
     if abs(own['pregrind_vely']) > abs(vely) and own['LAST_GRIND'] == 0:
119
-        convely = own['pregrind_vely']
119
+        #convely = own['pregrind_vely']
120
+        #print('changing convely')
121
+        convely = vely
120 122
     else:
121 123
         convely = vely  
122 124
     def grindvect(obj):
@@ -478,22 +480,25 @@ def main():
478 480
                 minDist = dist
479 481
         if nearestObject != None:                            
480 482
             own.linearVelocity.x = 0
481
-            own.linearVelocity.y = 0
482
-               
483
-            
483
+            own.linearVelocity.y = 0            
484 484
     
485
-    if grindDar.positive == False and grindTouch.positive and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0 and own['air_mover'] == False:
485
+    if grindDar.positive == False and grindTouch.triggered and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0 and own['air_mover'] == False:
486 486
         #print("touching, no dar")
487 487
         pass
488 488
     #print(grindold, "grindold")        
489
-    if grindDar.positive:
490
-        detectedObjects = grindDar.hitObjectList
491
-        dist = 0
492
-        for obj in detectedObjects:
493
-            dist = own.getDistanceTo(obj)
494
-            if (minDist is None or dist < minDist):
495
-                nearestObject = obj
496
-                minDist = dist     
489
+    if grindDar.positive or grindTouch.positive:        
490
+        if grindDar.positive:
491
+            detectedObjects = grindDar.hitObjectList
492
+            dist = 0
493
+            for obj in detectedObjects:
494
+                dist = own.getDistanceTo(obj)
495
+                if (minDist is None or dist < minDist):
496
+                    nearestObject = obj
497
+                    minDist = dist     
498
+        elif grindTouch.positive:
499
+            nearestObject = grindTouch.hitObject
500
+            dist = .7
501
+            #print('using touch object')                    
497 502
         
498 503
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@        
499 504
         #init grind
@@ -504,18 +509,12 @@ def main():
504 509
         else:
505 510
             own['inverting'] = False
506 511
         grind_dist = .8#.6
507
-        if dist < grind_dist and grindold == 0 and dropin == 0 and grind_jump == 0 and own["grindoutturn"] == 0 and gt_cd == 0 and manual == 0 and no_grind == 0 and nearestObject != lastObject and own['grindjumpturn'] == 0 and own['gt_cd2'] == 0 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0:   
508
-            #print("new grind trigger")           
509
-            npos = nearestObject.worldPosition
510
-            
511
-            
512
-        #grind
513
-        #print(dist)
514
-        if dist < grind_dist and dropin == 0 and grind_jump == 0 and manual == 0 and no_grind == 0 and own['airup'] == 0 and own['grindoutturn'] == 0 and own['grindjumpturn'] == 0 and own['manual'] == 0 and own['gt_cd2'] < 55 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0 and own['last_invert'] == False:
515
-            #print("grind")    
512
+
513
+        if dist < grind_dist and dropin == 0 and manual == 0 and no_grind == 0 and own['grindoutturn'] == 0 and own['manual'] == 0 and own['gt_cd2'] < 40 and invert_on == False and own['air_mover'] == False and no_grind_pull == 0 and own['last_invert'] == False and own['grindjumpturn'] == 0 and grind_jump == 0 and own['airup'] == 0:
514
+            #print('grind')      
516 515
             hitObject, hitPoint, hitNormal = own.rayCast(nearestObject.worldPosition, own.worldPosition, .0, 'grind')
517 516
             if grindold == 0:
518
-                if grindTouch.positive:
517
+                if grindTouch.triggered:
519 518
                     nearpos = nearestObject.worldPosition
520 519
                     if hitNormal != None:
521 520
                         stre = .05
@@ -523,8 +522,6 @@ def main():
523 522
                         #print("align")                   
524 523
                     own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
525 524
                     #print('moving world')
526
-
527
-
528 525
             #print("grinding")
529 526
             grind_height_dif = (own.worldPosition[2] - nearestObject.worldPosition[2]) - .287
530 527
             worldPos = own.worldPosition
@@ -534,8 +531,18 @@ def main():
534 531
                 grind(nearestObject)
535 532
                 grindold = True
536 533
                 own['grindold_timer'] = 0
537
-                own["grindHit"] = True                
538
-
534
+                own["grindHit"] = True
535
+                own['grindnew_timer'] += 1
536
+                
537
+                if own['grindnew_timer'] < 1:
538
+                    if grindTouch.triggered:
539
+                        nearpos = nearestObject.worldPosition
540
+                        if hitNormal != None:
541
+                            stre = .05
542
+                            own.alignAxisToVect(hitNormal, 2, stre) 
543
+                            #print("align")                   
544
+                        own.worldPosition = [nearpos.x, nearpos.y, nearpos.z + .2975]
545
+                        print('new moving world')                    
539 546
 
540 547
     else:
541 548
         #grindold = False 
@@ -548,7 +555,9 @@ def main():
548 555
         own['grind_start_frame'] = framenum
549 556
         own["grindSound"] = None
550 557
     
551
-    
558
+    if own['grindHit'] == False:
559
+        own['grindnew_timer'] = 0  
560
+ 
552 561
 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    
553 562
        
554 563
 #if you are touching grinder and last_manual is off keep manual off
@@ -616,9 +625,6 @@ def main():
616 625
         #own.alignAxisToVect(vect, 0, 0)
617 626
         own.worldPosition = [nearestObject.worldPosition.x, nearestObject.worldPosition.y, nearestObject.worldPosition.z +.1]
618 627
        #own.setLinearVelocity([0, 0.0, 0], 1)                    
619
-
620
-
621
-
622 628
             
623 629
     def set_pregrind_vel():
624 630
         if grindDar.triggered == False and ray.triggered == False:
@@ -639,9 +645,12 @@ def main():
639 645
         
640 646
     if grindDar_timer > 0:
641 647
         grindDar_timer -= 1
642
-    if grindDar_timer > 0 and ray.triggered == False and touched == True  and own['footplant_on'] == False and manual == 0:
648
+    if ray.triggered == False and touched == True  and own['footplant_on'] == False and manual == 0 and own['gt_cd2'] < 55 and own['grindoutturn'] == 0 and own['grindjumpturn'] == 0 :        
643 649
         obj = grindTouch.hitObject 
644
-        own.worlPosition = obj.worldPosition
650
+        try:
651
+            nearpos = obj.worldPosition
652
+        except:
653
+            pass    
645 654
     if ray.triggered == False:
646 655
         own["nogrindsound"] = 1                               
647 656
     timer()    

+ 2
- 1
scene_init.py View File

@@ -150,6 +150,7 @@ def main():
150 150
     cam['sun_pos_y'] = dict['sun_rot_y']
151 151
     #cam['shadow_on'] = dict['shadow_on']
152 152
     cam['dof_on'] = dict['dof_on']
153
-    cam['bloom_on'] = dict['bloom_on']    
153
+    cam['bloom_on'] = dict['bloom_on'] 
154
+    own['grindnew_timer'] = 0   
154 155
            
155 156
 main()

+ 6
- 2
walk.py View File

@@ -342,6 +342,9 @@ def onboard():
342 342
             trucks.stopAction(truckon)
343 343
             own['requestAction'] = 'fak_offboard'                          
344 344
 def jump():
345
+    #limit fall speed
346
+    if linvel.z < -10:
347
+        own.linearVelocity.z = -10
345 348
     if xBut == True or dict['kb_space'] == 1: 
346 349
         if own['lastx'] == 0:
347 350
             killact(3)
@@ -359,8 +362,9 @@ def jump():
359 362
             force = [ 0.0, 0.0, JUMPHEIGHT]
360 363
             # use local axis
361 364
             local = False
362
-            # apply force
363
-            own.applyForce(force, local)
365
+            # apply force -- limit jump speed
366
+            if linvel.z < 10:
367
+                own.applyForce(force, local)
364 368
         own['lastx'] = 1
365 369
     else:
366 370
         own['lastx'] = 0

Loading…
Cancel
Save