BGE Python Random Spawn Point (arsenal rsl YouTube channel)

Hi guys!

This is the code for the random spawn point tutorial I created (http://youtu.be/RzXcpFgiAD8).

Tutorial name: Blender Game Engine - part 66 - Random Spawn Point (Python)

Single arrow = 4 spaces or 1 tab key press
Double arrow = 4 spaces or 2 tab key presses

import bge
import random

def main():

–>cont = bge.logic.getCurrentController()
–>own = cont.owner

–>scene = bge.logic.getCurrentScene()

defines the three spawn points

–>one = scene.objects [“one”]
–>two = scene.objects [“two”]
–>three = scene.objects [“three”]

creates a list of spawn points

–>spawn_points = [one, two, three]

defines spacebar sensor

–>space = cont.sensors [“space”]

if the spacebar is pressed

–>if space.positive:
–>-->choice = random.choice(spawn_points)
–>-->own.worldPosition = choice.worldPosition

main()