Add object Naming. i think its delayed

im trying to make a splash object set up and i ran into a problem. my plan is to add the splash object and set its location via script. but it seams that there is a delay in the naming prosses, because the first time the script is run the object is created, but the position is not effected, the second time the scipt is run another object is created, and the original objects position is chaged. and if the script is run a third time the original object is moved and a third object is created. Im wondering how i can change my script to make it work.

Attachments

Water.blend (495 KB)

I haven’t looked at it, but imagine you are using the addObject actuator to add it by using “cont.activate()”?
What you can do is use instantAddObject instead.
So:
act = cont.actuators[“addObject”]
actObj = act.instantAddObject()
actObj.position = pos

I think. Have a look at the API, I’m going from memory here.


import bge
cn=bge.logic.getCurrentController()
own=cn.owner
hit=cn.sensors["Hit"]
if hit.positive:
  scene=bge.logic.getCurrentScene()
  newObj=scene.addObject("Splash",own)
  newObj.worldPosition=hit.hitObject.worldPosition

PS: check ever the consolle , that must be “black”!