pwolf
(pwolf)
April 30, 2012, 9:16pm
1
in the tutorial an f-curve is used, so i used to an action actuator in its place, however, i dont know how to script it to work with the action actuator, help is appreciated.
Im on this section of the series :
VIDEO
and here is the .blend file
Tunnel Runner.blend (461 KB)
pwolf
(pwolf)
April 30, 2012, 9:17pm
2
Here is the code in code blocks:
from bge import logic
import random
def _positionNewBlock(new_block, block):
AXIS = 0 # X
if block.name[0] == "H":
AXIS = 2 # Z
rand_range = block.worldPosition[AXIS]
rand = random.uniform(-rand_range, rand_range)
new_block.worldPosition[AXIS] = rand
def _fireObjects(list_objects, speed):
for gobj in list_objects:
gobj.setLinearVelocity([0, -speed, 0])
def _setFrameRange(new_block):
left = (0, 40)
right = (40, 80)
frame_range = random.choice((left, right))
Action = new_block.actuators["Crusher"]
Crusher.frameStart = frame_range[0]
Crusher.frameEnd = frame_range[1]
def spawn():
scene = logic.getCurrentScene()
blocks = (scene.objects["H_Block"], scene.objects["V_Block"],/
scene.objects["H_BlockSlider"])
block = random.choice(blocks)
new_block = scene.addObject(block, scene.objects["Spawner"])
_positionNewBlock(new_block, block)
if "Slider" in new_block.name:
_setFrameRange(new_block)
brace = scene.addObject(scene.objects["Brace"], scene.objects["Spawner"])
objects = (new_block, brace)
_fireObjects(objects, 180)
pwolf
(pwolf)
April 30, 2012, 9:19pm
3
p.s i know about the variable being named Action and me calling it as Crusher, thats not the problem though, just a mistake i forgot to fix when playing around!