controller logic (nand, etc.)

point of departure here is that i was wanting to have my main game object respond to simple arrow keys and the camera respond to shift + arrow key.

well, the obvious is to use shift on one sensor, then arrow on another and connect with and to give shift + arrow. but there are some problems:

  1. the sensor module distinguishes between left and right shift, so one would need to have the logic (left OR right) AND arrow. i can think of a fairly complicated way to create that (have a property get set based on left OR right shift being pressed, then join that property using AND to the appropriate arrow key) but it seems like there should be an easier way (?).

  2. using up arrow as example, clearly if shift AND up arrow are pressed, then up arrow is, too. so, i would presumably also need to change the logic for the object so that it moves only with up arrow but NOT shift pressed. i’m not sure how to set up that logic but am guessing that that’ the reason for having NAND, NOR, and XNOR in the controller logic. i just don’t understand how they work.

so, anyhow, what’s the best way to set up 2 versions of the arrow keys, 1 just normal and the other using shift + arrow?

Instead of over complicating your logic bricks, use properties to determine whether the shift key is down or not. In your camera/object movement logic, check the value of the shift key property, and move or don’t the object. I had a similar set up in a small fishing simulator I was working on a few weeks back where the mouse movement would move the fishing rod around, but holding Shift or Control key while moving the mouse would rotate the camera to look around the lake.

so would this be the right way to do that:

  1. create a property in the camera object called ‘shift’. set its value to false.

  2. create 2 keyboard sensors in camera/object for left and right shift. connect them both to an OR controller. connect the controller to a property actuator that sets the value of ‘shift’ to true.

  3. create a property sensor as well as an arrow keyboard sensor. property sensor is set to hold when the ‘shift’ property is true. connect both of these to an AND controller, and connect both of those to the motion you want.

  4. do the same thing with the object that gets moved with arrows, except require that the ‘shift’ property be false AND the arrow key be pressed for the motion to occur.

is that the right technique?

one problem i see trying the above is that the property doesn’t revert to false when i release the shift keys. sorry to ask so many stupid questions, but … how do i get it to do that?

The way I had it set up, I had an empty in my scene which contained some “global” properties, such as “lookMode” (When Shift or Control was down, this was set to True, when it was released it was set to False). In my camera and fishing rod, I set up Mouse-Move sensors hooked to a python controller, the python scripts for the camera and rod would get the value of the “lookMode” property from the empty object, depending on the value of “lookMode” it would activate the actuators connected to that object.

I’ve just made a quick example, use W/S to move the cube forwards and backwards, hold left shift then use W/S to move the camera forwards and backwards.


camera.blend (135 KB)

i’m taking that also as my intro to how to use python in blender, for which i’ll certainly have to familiarize myself with some classes and modules. but i at least have a vague idea now as to how it’s working–enough so that i think i can just make some mechanical changes to your code to get it to do what i want for now.