Random placement python script problem

The add location random placement script stops working.Please press p to test.
How could i fix this problem?
https://drive.google.com/file/d/0BzuF6UUL8chvZXY1ZGxEZ3F1XzA/view?usp=sharing

Depends on what you call stop working. what is your blend doing at all?
I see a cube that falls goes trough the floor and keeps falling.

What will be placed random?
Also i see you use random.uniform(never worked with it) to set a location/vector. Is it not easier to use empties as ‘spawn locations’?
Or use an object position directly place a few spots into a list and use random.choice() to grab a random one out of the list.

But the main question is, what does your blend needs to do?

I was going to place a building which is actually cube.051 randomly over a particular terrain tile.I was going to place a gas tank randomly over a particular terrain tile.Then cause that particular terrain tile to get flat with the replace mesh actuator.And when i went away.Then came back to that terrain tile in the endless runner game it would be flat.I was going to do it with python and logic bricks.

for something like that I would use an proxy mesh with some (more) vertex points.

  • get any position of each vertex from the proxy mesh
  • set up an list of items that you want to spawn
  • pick randomly from that list the items to spawn (it can be more than one)
  • and for each item object set random an new position depends on the proxy vertex position

I have done that before in my games like that, I can provide you an .blend

You can also spawn the player at an random place separately from another proxy mesh if he fall down.

test_demo:
spawn_items_players.blend (921 KB)

Remember this is for spawned terrain of a endless runner game.

it is perfect for that

you can every time expand the proxy mesh with predefined areas

Spawn one building and gas tank on one randomly selected terrain tile in a endless runner.
Your script is really too complex.I would rather not use a proxy mesh.

why not?

if you have an “path tile” from your “endless runner” game then you can give this part tile an parent or an property that have the information about the shape (or where builds can spawn or not) for each “path tile” that spawn you have only to reactivate (update) the active “path tile” one time.

or

you can predefined some masks (lets say you have 10 different “path tiles”) you can have for each “part tile” the same proxy mesh or an different depends on what you have in the “proxy mesh list” from that you can pick randomly one proxy mesh for your “path tile” and for each “proxy mesh” you choose on which vertex random should spawn your random buildings from your “items list” <- should renamed to buildings list

There are hardly any more randomness

random inception (dooooommm) <- just kidding

Your python script is way too complex for me to understand.

that is another story.

then learn a bit more python.

very nice effect, only thing is what is the key to close it haha ESC wont work.

@lost
you can just parent a few empties to the plane, grab all the empties when needed let python grab a random one and then spawn whatever you want at that empty.

oh I am sorry I bind my exit key to RETURN/ENTER because of binding menus key every time to ESC (like in real games)

but thanks for looking at it