What does this mean?Here is the script to.
Python script error - object 'Empty', controller 'Python':
Traceback (most recent call last):
File "C:\Users\barbara\Desktop\endless_runner_v1.2a.blend\endless_lane.py", line 60, in create
SystemError: gameOb.getDistanceTo(value): KX_GameObject, Blender Game Engine data has been freed, cannot use this python variable
Blender Game Engine Finished
import random
def create(cont):
own = cont.owner
scene = own.scene
if not 'last_added' in own:
own['added_before'] = []
own['last_added'] = None
own['ground_objects'] = [obj for obj in scene.objectsInactive if 'ground' in obj]
add_object(cont)
return
player = scene.objects['player']
ground_plane_size = 30.0 # Y direction / used as an offset
ground_plane_down = -3.0
spawn_distance = ground_plane_size /2 # min: of choice, max: ground_plane_size (from origin)
remove_distance = ground_plane_size # min: ground_plane_size , max: of choice (from origin)
spawn_distance2 = ground_plane_down /8 #
remove_distance2 = ground_plane_down
# origin = the orange dot you see when you have an object selected, move object in edit mode(tab)
# to change the origins position, or select all and hit shift+s then 3d cursor to selected and in
# object mode select the object hit ctrl+shift+alt+c and place it at the 3d cursor to center it.
# it is used at to check distances, so if things go wrong check the origin/distances
# i suggest to keep the origin at the center and at the top of the ground plane
if own['last_added']:
distance_to_last_added = player.getDistanceTo(own['last_added'])
random_height = random.choice([-1, 0, 1]) # ground plane spawn heights
if distance_to_last_added < spawn_distance:
own.worldPosition.y += ground_plane_size
own.worldPosition.z = random_height
add_object(cont)
if distance_to_last_added < spawn_distance2:
own.worldPosition.z += ground_plane_down
add_object(cont)
if own['added_before']:
for obj in own['added_before']:
distance_to_added_before = player.getDistanceTo(obj)
if distance_to_added_before > remove_distance:
own['added_before'].remove(obj)
obj.endObject()
def add_object(cont):
own = cont.owner
scene = own.scene
added_object = scene.addObject(random.choice(own['ground_objects']), own, 0)
if own['last_added']:
own['added_before'].append(own['last_added'])
own['last_added'] = added_object