# Controlling 2 objects

**URL:** https://forum.kirupa.com/t/controlling-2-objects/44247
**Category:** Uncategorized
**Created:** [March 2, 2004, 3:38am UTC](https://forum.kirupa.com/t/controlling-2-objects/44247 "2004-03-02T03:38:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![xzero](https://avatars.discourse-cdn.com/v4/letter/x/a9adbd/32.png) [@xzero](https://forum.kirupa.com/u/xzero)
#### Post date: [March 2, 2004, 3:38am UTC](https://forum.kirupa.com/t/controlling-2-objects/44247/1 "2004-03-02T03:38:52Z")

</div>

hi, im trying to make a movie, that the user can control two objects at different time. A variable will act as a switch to determine which object should be controlled by the user. The following codes are written:

Frame 1:  
\_global.intObj1 = “1”;  
\_global.intObj2 = “0”;

Obj1:  
on (press) {  
intObj1 = 0;  
intObj2 = 1;  
}  
on (keyPress “\<Left\>”) {  
if (intObj1 == 1) {  
object1.\_x = 412;  
}  
}  
on (keyPress “\<Right\>”) {  
if (intObj1 == 1) {  
object1.\_x = 212;  
}  
}

Obj2:  
on (press) {  
intObj2 = 0;  
intObj1 = 1;  
}  
on (keyPress “\<Left\>”) {  
if (intObj2 == 1) {  
object2.\_x = 412;  
}  
}  
on (keyPress “\<Right\>”) {  
if (intObj2 == 1) {  
object2.\_x = 212;  
}  
}

only object1 can be controlled by the user, object2 is somehow disabled, even tho intObj2 = 1. If anyone knows how to fix my problem, or needs clarification, please reply right away, thank you!!
