I have a World model, where I use hitPosition data to determine where on the World model I’m clicking. I want to, onClick, add a model who’s name is stored in the world model properties (here shown as objectToAdd). If I replace (pX, pY, pZ) with “World”, the building I’m adding is added to the World’s center. I want to add the building at the place I’m clicking (pX, pY, pZ). But I’m not sure how to do this. Help?
When I MouseOver the World model
from bge import logic cont = logic.getCurrentController() own = cont.owner mouseoverany = cont.sensors["MouseOverAny"] own['pZ'] = mouseoverany.hitPosition.z own['pX'] = mouseoverany.hitPosition.x own['pY'] = mouseoverany.hitPosition.y
When I Left-Click
from bge import logic cont = logic.getCurrentController() own = cont.owner scene = logic.getCurrentScene() newObject = own['objectToAdd'] pX = own['pX'] pY = own['pY'] pZ = own['pZ'] scene.addObject(newObject, (pX,pY,pZ), 0)