Browse Source

fixing nothing

shuvit 4 years ago
parent
commit
afbb3ce1d0
4 changed files with 23 additions and 22 deletions
  1. 0
    3
      assets/roads1.blend
  2. 0
    3
      assets/roads4.blend
  3. 21
    14
      scripts/StatesCar.py
  4. 2
    2
      scripts/cars.py

+ 0
- 3
assets/roads1.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:d9a849f17050b8d2343334386d20b8f84e93c0c8263081f918664c9867d2eab1
3
-size 83062088

+ 0
- 3
assets/roads4.blend View File

@@ -1,3 +0,0 @@
1
-version https://git-lfs.github.com/spec/v1
2
-oid sha256:ed2ab233152474e80d0e10406df1f6853b5a1c4ea5fdfeca97232ae82ea1e59b
3
-size 19659180

+ 21
- 14
scripts/StatesCar.py View File

@@ -77,18 +77,20 @@ def find_new_parking(self):
77 77
         mark_path(path, self)
78 78
         return new_parking, path
79 79
     else:
80
+        print('cant find parking for', self)
80 81
         self.FSM.FSM.ToTransition('toEnterParallelPark')
82
+
81 83
 def get_lane_point(self):
82 84
 
83 85
 
84 86
     self.point = self.path[self.path_index]
85 87
     #print(self.path_index, 'path index')
86
-
87
-    v = Vector([self.last_lane_point.x - self.point.x, self.last_lane_point.y - self.point.y, 0])
88
-    tv = v.normalized()
89
-    nv = Vector([-tv.y, tv.x, 0]) #rotate 90 degrees
90
-    self.last_lane_point = self.lane_point
91
-    self.lane_point = self.point + self.manager.lane_position * nv
88
+    if self.point != self.last_lane_point:
89
+        v = Vector([self.last_lane_point.x - self.point.x, self.last_lane_point.y - self.point.y, 0])
90
+        tv = v.normalized()
91
+        nv = Vector([-tv.y, tv.x, 0]) #rotate 90 degrees
92
+        self.last_lane_point = self.lane_point
93
+        self.lane_point = self.point + self.manager.lane_position * nv
92 94
 
93 95
 
94 96
 
@@ -124,7 +126,9 @@ def delta_to_vect(self):
124 126
     delta_mult = -.1
125 127
     mult = 1.0
126 128
     deltamove = delta[2] * delta_mult
127
-    self.obj.applyMovement([0, deltamove, 0], True)
129
+    #self.obj.applyMovement([0, deltamove, 0], True)
130
+    f = deltamove * 5000
131
+    self.obj.applyForce([0, f, 0], True)
128 132
             
129 133
               
130 134
 def apply_gas(self):
@@ -224,19 +228,22 @@ class EnterParallelPark(State):
224 228
         self.FSM.owner.obj.applyMovement([0, -6, 0], True)
225 229
         self.FSM.owner.target.status = 'in_use'
226 230
         self.FSM.owner.obj.worldPosition.z += .9
227
-        self.FSM.owner.obj.suspendDynamics()
228
-        self.FSM.owner.obj.suspendPhysics()
229
-        self.FSM.owner.manager.cars_active.remove(self.FSM.owner)
230 231
         self.FSM.owner.active = False
231 232
         self.FSM.owner.start_empty = self.FSM.owner.target
232
-        self.FSM.owner.last_point = self.FSM.owner.obj.worldPosition
233
-        self.FSM.owner.point = self.FSM.owner.obj.worldPosition
233
+        self.FSM.owner.last_point = self.FSM.owner.target.obj.worldPosition.copy()
234
+        self.FSM.owner.last__lane_point = self.FSM.owner.obj.worldPosition
235
+        self.FSM.owner.point = self.FSM.owner.target.obj.worldPosition.copy()
236
+        
234 237
         clear_markers(self)
238
+        
239
+        self.FSM.owner.obj.suspendDynamics()
240
+        self.FSM.owner.obj.suspendPhysics()
235 241
         super(EnterParallelPark, self).Enter()        
236 242
         
237 243
     def Execute(self):
238 244
         self.FSM.stateLife += 1
239
-    
245
+        if self.FSM.stateLife == 2:
246
+            self.FSM.owner.manager.cars_active.remove(self.FSM.owner)
240 247
         #self.FSM.ToTransition('toActivate')
241 248
         
242 249
 
@@ -266,7 +273,7 @@ class NavigateToTarget(State):
266 273
         #print('target', self.FSM.owner.target.obj.worldPosition)
267 274
 
268 275
         #emergency exit
269
-        if self.FSM.stateLife > 60 * 90:
276
+        if self.FSM.stateLife > 30 * 60:
270 277
             self.FSM.ToTransition('toEnterParallelPark')
271 278
 
272 279
         #print('doing NavigateToTarget')

+ 2
- 2
scripts/cars.py View File

@@ -85,7 +85,7 @@ class CarManager:
85 85
 		self.navmesh =None
86 86
 		self.cars = []
87 87
 		self.max_cars = 15
88
-		self.max_active = 7
88
+		self.max_active = 9
89 89
 		self.targets = []
90 90
 		self.target_loc = None
91 91
 		self.parking_spots = get_parking_spots()
@@ -177,7 +177,7 @@ class CarManager:
177 177
 		self.life += 1
178 178
 		if self.cars_loaded:
179 179
 			#check i f new car should be active
180
-			if self.life % 360 == 0:
180
+			if self.life % 180 == 0:
181 181
 
182 182
 				self.activator_check()
183 183
 

Loading…
Cancel
Save