Jump to content

Blender 3D Reference Guide/Buttons Reference/Logic

From Wikibooks, open books for an open world

Okay, one day I decided that I wanted to do something. This is it.


Anyway. This Logic Brick tutorial is for the people who know the basics of everything but logic bricks, pretty much. Let's get started.

Create a cube. Now in the Logic brick panel (purple pacman button), click "add" for all three of the little panelly things.

But first, here are the descriptions.
SENSORS: These are what have to happen to play out the actuator. EG: mouse click, keyboard press "H".
CONTROLLERS: Best described, these are just a walkway for the sensor to activate the actuator (in 98% of the cases, but don't get confused now...)
ACTUATORS: These are what happens when it detects that the sensor has happened. EG: animation from frame 1 to 100, movement / 100 places to the left.

In the first little panel, click on the arrow next to the word "always". (Not the orange one, the near invisible silver one RIGHT next to it.) Now click on keyboard. In the space next to the word "key," click in and type any keyboard button you want. Now click and hold on the little yellow next the logic brick. Drag it to the yellow orb on the side of the controller logic brick. What you have just done is linked the sensor to the controller, so that when you link the controller up to the actuator something will happen.

Now, in the movement actuator logic brick, click in the first "dloc" space, and type the number ".5". Now, link up the broken logic bricks, and voila! You have made your first interactive 3d content. Well, that's what I'm guessing if you've never used any other 3D program that makes interactive stuff, or if you've never made maps in TimeSplitters 3, but what the heck.

Start the game, and press the keyboard button that you entered into the sensor logic brick before. WOW! The cube moved! The cube actually moved in the co-ordination of where you typed ".5". Those three tiny panels in each of the "dloc"s and the "torque"s rows, are different dirrections, x y and z, with all of the rotation command exceptions and crap or whatever.

Now, let's do something fancy. Do you want the camera to follow the cube when you are moving it? Probably not, but anyway... To do this, go into animation mode, and add a camera that's looking straight at the cube. Now, in the big panel on the left, click on the camera. Add in a logic brick for all three of the panels (in the logic section), and leave the sensor on always. This means that this actuator is always going to happen in the game. ALWAYS. And yes, you can create an always sensor and a "quit game" actuator, but it's pretty gay, because as soon as you start the game, it quits!

Anyway... in the actuator logic brick, click on the near invisible arrow next to "motion", and click on "edit object". With the new options, click on the arrow of the tiny selection pop-up bar, and click on "track to". This will make the camera look at the object at all times. (Because of the always sensor, of course.) But in the other tiny empty bar that comes up, click on and type in the name of the cube that is displayed in the panel to the left of the screen. Most likely "Cube". DAHHHHHH! Now play the game, and move the cube. YES! you've done it. Have you? If you've done it right, you will have a moving cube and a tracking camera.

You can make objects other than the camera follow another object, so have fun with your tracking and movement knowledge.