Hi everyone,
I followed a tutorial recently on how to spawn objects randomly, but is seems to me they calculate the spawnpoint from the worlds 0 point. Now i want them to spawn near an object, so from the local position of this object. So i would add a collisionsensor to an object which sends a message to an empty that there should spawn an object within some limited distances near that object again.
Here’s tyhe tutorial i followed https://www.youtube.com/watch?v=126i_aO1OoE
I have this code so far:
Code:
import bge
import random
scene = bge.logic.getCurrentScene()
Spawnpoint = scene.objects [“Spawnpoint”]
class PlatformspawnClass:
def init(self, x, y, z):
self.x = x
self.y = y
self.z = z
Spawnpoint.position = (x,y,z)
scene.addObject(“Platformspawn”, Spawnpoint, 100)
xPosition = random.randint(-3,3)
yPosition = random.randint(1,3)
zPosition = random.randint(1,3)
object1 = PlatformspawnClass(xPosition, yPosition, zPosition)
And this works pretty fine so far, they spawn near the origin point of the world, what can i change in the code to make them spawn near my object where this script is attatched to?Thanks in advance