Object swapping

So what i thought i had working for object swapping for my game isnt working so came here for help, basically what i need to do is have is one cube when clicked on in first person view in game to some how tell the game that is selected and then when you click on another object it changes to the first cube you selected and the then the first object automatically changes to the second object. and all the objects in game are cubes right now there is a basic block witch can swap with anything and there is a fire emitting block and a glass block that forms when sand blocks touch a flame but the sand block you dont swap just when it turns to glass but but other blocks besides the basic block can only swap with the basic block and not whith any other, also ill be adding more blocks down the road. So i know this kinda confusing but if anybody could so me how to do it would be very gratefull! :slight_smile: also was using logic bricks but scripting would work to.

oh and i forgot you can only swap 2 blocks at a time meaning when you click one and then right click or whatever the other one that ends the current swap i guess you can call it so this way you cant click on a block and then go changing the whole room to the same block.

you can simply switch the location/orientation/scale

The remaining things like selecting, unselecting are simple too. But in combination it is quite a complex logic.

Therefore I prepared you a quick Demo. You can use the ObjectSwitcher object in your file as well.

Installation into your file:
A)

  • link or append Szene “_ObjectSwitcher.lib”
  • add instance “ObjectSwitcher” to your scene

B)

  • link or append Group “ObjectSwitcher”
  • add instance “ObjectSwitcher” to your scene

C)

  • link or append Object “ObjectSwitcher.ctrl”
  • add instance “ObjectSwitcher” to your scene

See AAREADME for more details.
Attention: The configuration property “includes” is configured in the group object ObjectSwitcher.ctrl. The default contains “selected, selectable”

Monster

Attachments

ObjectSwitcher.blend (73.1 KB)

thanks! so much!

so basically to put this into my game i append the Szene “_ObjectSwitcher.lib” and all the other scenes into the game and all the switchable cubes in the game i just copy the properties and logic that are in the objects in the .blend you sent me and then what do you mean by add instance “MessageAnalyzer” to your scene?

You append _ObjectSwitcher.lib. This adds the group to your file. You do not need the other scenes. Just the group (or a scene with the group).

Then you can add an instance ObjectSwitcher to your game scene.
Now you add the property “selectable” to your switchable boxes. That is all.

Advanced:
If you want to mark your box as selected you can use a property sensor that checks “selected” to be True. With that you can trigger whatever you want.

Sorry MessageAnalyzer is incorrect (copy&paste-Error :(). The group is named ObjectSwitcher.

Please keep in mind. This is just a demo. You can switch any selectable object with any other selectable object.
There is no “switch A with B but not with C” thing implemented. That requires some more work.

ok thanks i think i got it working now, and ya thats ok this will work for now for the competition. i just have one more question hopefully its a quick fix. The game is in first person view and for some reason i cant select things and the cursor is stuck to the middle of the screen even when i look around, so is there a way to getting the selection to work in first person?

any ideas?

I think you are using a “mouselook”. THe common method is to use relative mouse movement. To avoid leaving the screen the mouse is set back to the middle of the screen.

That means you can only select things under the middle of the screen.

An alternative would be to temporary switch on and off the mouselook logic.

ya i tried that i added logic in the player witch holds the mouselook system to go into state 2 when left or right mouse button is clicked then on state 2 i have a delay of 2 and then sets it back to state 1, but it still doesnt work.

is that kinda what you ment or something diffrent?