I am really confused what is going on right now with my factory objects.
I have 4 different factory (fac1, fac2, fac3, fac4) and I am spawning only one object from each factory
each factory has one prototype object that already has his own script, and each script has unique variable:
fac1 prototype has variable:
self.name 1= name1
fac2prototype has variable:
self.name2 = name2
fac3 prototype has variable:
self.name3= name3
fac4 prototype has variable:
self.name4 = name4
In control script I have stored 4 different positions
pos1 = vmath.vector3(something)
pos2 = vmath.vector3(something)
pos3 = vmath.vector3something)
pos4 = vmath.vector3(something)
then from init in control script I am spawning them:
object1 = factory.create(fac1, pos1)
object2 = factory.create(fac2, pos2)
object3 = factory.create(fac3, pos3)
object4 = factory.create(fac4, pos4)
each factory object script also has touch detection to identify their names:
if message_id == hash(“collision_response”) then
print(self.name) – or self.name2, self.name3, depends which object is collided on touch
end
when they are spawned from init, on touch collision, I am receiving correct self.name variables for each of 4 objects. HOWEVER,
If I change their positions, in reverse for an example:
go.set_position(pos4, object1) --previous position was pos1
go.set_position(pos3, object2) --previous position was pos2
go.set_position(pos2, object3) --previous position was pos3
go.set_position(pos1, object4) --previous position was pos4
I can see that they accept new positions (visually), but when I touch them, self.name variables are not the one they initially had. Instead, they have variables from object that was previously on that position.
Example:
If object1 with its own variable self.name1 had pos1 and
and
object2 with its own variable self.name2 had pos2…
…when I move object1 to pos2, and object2 to position1,
object2 will now have variable self.name1 instead self.name2,
and object1 will have variable self.name2 instead it’s own initialized self.name1
How’s that possible?!