Browse Source

npc origins

shuvit 4 years ago
parent
commit
598154c10e

+ 1
- 1
assets/user2.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:1f24f97dbd1be9394811c0c5ca1ef2f42a07da4fae255bad599ab261f214e50d
2
+oid sha256:b5462737156707708069790b93349c0ce1a35524db2a57fa43e11aaf5c7a5d19
3 3
 size 6860928

+ 3
- 0
assets/utils/building_genV2_1.blend View File

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

+ 2
- 2
npc_walkers/larry.blend View File

@@ -1,3 +1,3 @@
1 1
 version https://git-lfs.github.com/spec/v1
2
-oid sha256:3f20d8d1e3b7b809089f2483347932b2d5d40e37ed3ae11df37f0981236b034e
3
-size 3687104
2
+oid sha256:dcfb9f4e7338db59784f183eb08030a73aef2883fb6ab1584dce2db9b2820bf2
3
+size 3686384

+ 11
- 3
scripts/StatesWalker.py View File

@@ -120,6 +120,11 @@ def apply_gas(self):
120 120
     if self.obj.linearVelocity.x < self.speed_targ:
121 121
         self.obj.applyForce([self.speed_inc, 0, 0], True)
122 122
 
123
+def walk_anim(self):
124
+    if self.obj.linearVelocity.x > .5:
125
+        arm = self.obj.children['npc']
126
+        arm.playAction('g_walk2', 1,62, layer=1, play_mode=0, speed=.5) 
127
+
123 128
 #====================================     
124 129
 
125 130
 State = type("State", (object,), {})
@@ -144,9 +149,10 @@ class Example(State):
144 149
         
145 150
     def Enter(self):
146 151
         self.FSM.stateLife = 1
147
-        self.FSM.owner.resumePhysics()
148
-        self.FSM.owner.resumeDynamics()
149
-        print('physics resumed')
152
+        #self.FSM.owner.obj.worldPosition = self.FSM.owner.start_empty.obj.worldPosition
153
+        #self.FSM.owner.resumePhysics()
154
+        #self.FSM.owner.resumeDynamics()
155
+        #print('physics resumed')
150 156
         super(Example, self).Enter()        
151 157
         
152 158
     def Execute(self):
@@ -235,6 +241,7 @@ class NavigateToTarget(State):
235 241
         set_height(self.FSM.owner)
236 242
         delta_to_vect(self.FSM.owner)
237 243
         apply_gas(self.FSM.owner)
244
+        walk_anim(self.FSM.owner)
238 245
 
239 246
         if self.FSM.stateLife > 30 * 180 * 3:
240 247
             self.FSM.ToTransition('toEnterParallelPark')
@@ -281,3 +288,4 @@ class RequestPath(State):
281 288
         self.FSM.stateLife += 1
282 289
 
283 290
     def Exit(self):
291
+        pass

+ 1
- 1
scripts/cars.py View File

@@ -135,7 +135,7 @@ class CarManager:
135 135
 			self.cars_active.append(car)
136 136
 			car.active = True
137 137
 			car.FSM.FSM.ToTransition('toRequestPath')
138
-			print('activate car', car)
138
+			#print('activate car', car)
139 139
 
140 140
 	def update(self):
141 141
 		self.life += 1

+ 26
- 24
scripts/walker_states.py View File

@@ -1,3 +1,4 @@
1
+#not used - delete
1 2
 import bge
2 3
 from random import randint
3 4
 from time import clock
@@ -314,33 +315,34 @@ class Walker(Char):
314 315
 		self.npcFSM.Execute()    
315 316
 
316 317
 #====================================     
317
-r = Walker()
318
+#r = Walker()
318 319
 def main(cont):
319
-	own = cont.owner   
320
-	scene = bge.logic.getCurrentScene()
321
-	if 'inited' not in own:
322
-		own['inited'] = True
323
-		own['frame'] = 0
324
-		own['state'] = 'On'
325
-		own['navMesh'] = None
320
+	pass
321
+	# own = cont.owner   
322
+	# scene = bge.logic.getCurrentScene()
323
+	# if 'inited' not in own:
324
+	# 	own['inited'] = True
325
+	# 	own['frame'] = 0
326
+	# 	own['state'] = 'On'
327
+	# 	own['navMesh'] = None
326 328
 
327
-		for x in scene.objects:
328
-			if 'npcNavmesh' in x:
329
-				own['navMesh'] = x
329
+	# 	for x in scene.objects:
330
+	# 		if 'npcNavmesh' in x:
331
+	# 			own['navMesh'] = x
330 332
 
331
-	if own['frame'] == 40:
332
-		own.worldPosition = [0,0,50]	
333
+	# if own['frame'] == 40:
334
+	# 	own.worldPosition = [0,0,50]	
333 335
 
334
-		ln = own['cName'] + '_loader'
335
-		if ln in scene.objects:
336
-			to = scene.objects[ln]	
337
-			own.worldPosition = to.worldPosition
338
-			own.worldOrientation = to.worldOrientation
336
+	# 	ln = own['cName'] + '_loader'
337
+	# 	if ln in scene.objects:
338
+	# 		to = scene.objects[ln]	
339
+	# 		own.worldPosition = to.worldPosition
340
+	# 		own.worldOrientation = to.worldOrientation
339 341
 
340
-	r.Execute()    
342
+	# r.Execute()    
341 343
 
342
-	own['frame'] += 1
343
-	yvel = own.linearVelocity.y
344
-	yvel = yvel *.05
345
-	if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01:
346
-		own.applyRotation([0,0,yvel], True)		
344
+	# own['frame'] += 1
345
+	# yvel = own.linearVelocity.y
346
+	# yvel = yvel *.05
347
+	# if own.linearVelocity.y > .01 or own.linearVelocity.y < -.01:
348
+	# 	own.applyRotation([0,0,yvel], True)		

+ 13
- 4
scripts/walkers.py View File

@@ -9,19 +9,22 @@ car_colors = [[.2,.01,.01,1], [.5,.5,.4,1], [.005,.01,.015,1], [.005, .1, 0.003,
9 9
 def idle_run_check(self):
10 10
 	output = False
11 11
 	for x in bge.logic.getCurrentScene().objects:
12
-		if 'walker_idle_empty' in x.name:
12
+		if 'walker_idle_spot' in x.name:
13 13
 			self.idle_spots.append(x)
14 14
 			x['in_use'] = False
15 15
 			output = True
16
+	print(output, 'walker idle spots')
16 17
 	return output
17 18
 			
18 19
 
19 20
 def get_idle_spots():
20 21
 	op = []
21 22
 	for obj in bge.logic.getCurrentScene().objects:
22
-		if 'idle_spot' in obj:
23
+		if 'idle_spot' in obj.name:
23 24
 			ps = IdleSpot(obj, 'available')
24 25
 			op.append(ps)
26
+	print('&&&&&& idle spots')
27
+	print(op)		
25 28
 	return op
26 29
 
27 30
 def get_intersections():
@@ -32,9 +35,13 @@ def get_intersections():
32 35
 	return op		
33 36
 
34 37
 def add_walker(self, x):
38
+	print(x.obj.worldPosition, '--walker here')
35 39
 	walker = bge.logic.getCurrentScene().addObject('larryCube', x.obj, 0)
40
+	print(walker.worldPosition)
41
+	
42
+	#walker.worldPosition = x.obj.worldPosition
36 43
 	walker.worldOrientation = x.obj.worldOrientation
37
-	walker.worldPosition.z += .8
44
+	walker.worldPosition.z += 2.8
38 45
 	walker.name = 'lwalker' + str(len(self.manager.walkers))
39 46
 	x.status = 'in_use'
40 47
 
@@ -64,6 +71,7 @@ class Walker:
64 71
 		self.path_index = 0
65 72
 		self.path_display = []
66 73
 		self.manager.pub.register("path found", self)
74
+		#self.obj.worldPosition = self.start_empty.obj.worldPosition
67 75
 
68 76
 	def Execute(self):
69 77
 		self.FSM.Execute()
@@ -117,7 +125,7 @@ class WalkerManager:
117 125
 			path = bge.logic.expandPath(fileName)
118 126
 			print('loading npc')
119 127
 			try:
120
-				bge.logic.LibLoad(fileName, 'Scene') 
128
+				bge.logic.LibLoad(fileName, 'Scene', load_actions=True) 
121 129
 				print('larry loaded')
122 130
 			except Exception as e:
123 131
 				print('loading', fileName, 'failed', e)   
@@ -131,6 +139,7 @@ class WalkerManager:
131 139
 			walker = random.choice(l)
132 140
 			self.walkers_active.append(walker)
133 141
 			walker.active = True
142
+			walker.obj.worldPosition = walker.start_empty.obj.worldPosition
134 143
 			walker.FSM.FSM.ToTransition('toRequestPath')
135 144
 
136 145
 	def update(self):

Loading…
Cancel
Save