Hi,
I made a little script that adds blocks ontop of eachother with a ray that randomly goes over a grid.
The ray sensor “hitground” is targetting “grass” blocks and is moved a random amount between -1 and 1 every tick.
How can I specifically target the Z axis of the hitPosition to check if the Z axis of the hitPosition isn’t higher then a certain number? ( I want to use this so I can add rock blocks if the Z axis is higher then let’s say 5 )
Here’s the code for adding in blocks:
if own['randnum'] > -5000: own['randnum'] -=1
pos = [own['x'],own['y'],own['z']]
holder.worldPosition = pos
if hitground.positive:
pos = [own['x'],own['y'],own['z']]
if hitground.hitPosition <= [50,50,5]:
object = scene.addObject(randob[0],'grid')
object.worldPosition = hitground.hitPosition
own['x'] +=randint(-1,1)
own['y'] +=randint(-1,1)
if own['x'] > 50:
own['x'] = 50
if own['y'] > 50:
own['y'] = 50
if own['x'] < 0:
own['x'] = 0
if own['y'] < 0:
own['y'] = 0
The last piece of code specifies that the sensor won’t go over an X and Y of 50.
I tought of something like:
if hitground.hitPosition <= [50,50,5]:
But that won’t take Z axis in account.
Any ideas?