using object properties

You click on the first button of the control panel at the front. This inserts an object instance, you can then left click on it and right click to snap it to other object. But if you insert a second instance you can only move the first.

So i created a different property for each instance.

But how do i intergrate the property into the move script (in “text”)?

so each object instance can be moved independently?

Attachments

mouse click rev 5.blend (329 KB)

Added objects have the same name. Therefore you can’t distinuish between them.
So do not use the names. Use the object references:

cont = GameLogic.getCurrentController()
scene = GameLogic.getCurrentScene()
own = cont.owner
mouseOver = cont.sensors["mouseOver"]
mouseLclick = cont.sensors["mouseLclick"]
mouseRclick = cont.sensors["mouseRclick"]
#objlist = scene.objects
#maskGroup = state2.mask
#print objlist
#object = objlist['OBfinal']
#print "object is...",object
#print maskGroup
#time = own["time"]
#state2 = cont.actuators["state2"]
#stateof =1
gameObj = mouseOver.hitObject 
if mouseOver.positive and mouseLclick.positive and gameObj.has_key("snap"):
 
 own["LeftClick_Object"] = mouseOver.hitObject
 
 print "*********** FIRST SELECTED IS... " + mouseOver.hitObject.name
 #print "name is...",mouseOver.hitObject
 
 
 #own["toggle"] = 1
 #print "the first time is...", time
 
 #prop = gameObj
 
 #print prop
 #act.mask = 2
 #state2.mask = 1
 #stateof = 2
 
 #tate2 = True
 #stateof = 2
 
 
elif mouseOver.positive and mouseRclick.positive and own["LeftClick_Object"] != "":
 
 RightClick_Object = mouseOver.hitObject
 
 RightClick_Object_Pos = RightClick_Object.localPosition
 RightClick_Object_Ori = RightClick_Object.localOrientation
 
 
 LeftClick_Object = own["LeftClick_Object"]
 LeftClick_Object.localPosition = RightClick_Object_Pos
 LeftClick_Object.localOrientation = RightClick_Object_Ori
 
 
 own["LeftClick_Object"] = ""
 print "************ SECOND SELECTED IS... " + RightClick_Object.name
 
 #object = gameObj
 #print "the second time is...", time
 #print pos
 #print orient
 #orient = finObj.worldOrientation
 #own["toggle"] = 0
 
 #stateof = 1
 #state1.mask = 2

This works with 2.49+ as with 2.49 you can store KX_GameObjects in object properties.

I hope it helps

Thanks.

I did not know how to use the object ref. But that made it clear.