I am trying to teleport an object to where a player clicks on screen. Does anybody have a solution?
import bge cont = bge.logic.getCurrentController() own = cont.owner if own['Time']>=1: own['Time']-=1 MOA = cont.sensors['MouseOverAny'] Click = cont.sensors['Click'] #select object to move if MOA.positive and Click.positive: if 'Target' not in own and own['Time']==0: own['Target']=MOA.hitObject own['Time']=30 elif own['Time']==0: own['Target'].worldPosition=MOA.hitPosition own['Target'].applyMovement((0,0,1),1) del own['Target'] own['Time']=30
This is what happens:
edited code slightly
adding own, and apply movement
ClickGrabPlacePlop.blend (421 KB)
Thanks, that worked! I needed to modify it slightly to get the desired effect, but it worked great!