The Blog

About Me


Marius Oberholster Hey! I'm having an incredible learning experience, not only learning how Blender works (yes, still learning), but also about Open-Source and the incredible software available. Stick around!

Keyboard sensor and controls

Posted by Marius Oberholster on Wednesday, January 15, 2014 Under: Quick Blog Tutorial
Good day all!

Hope your week is going really well! Today's QBT is on using keyboard controls in BGE.

It is super simple and you're gonna luv it if you don't know it just yet:

(Pardon bad grammar, it is a very quick and rough example)

In order to control an object with the keyboard, you use the Keyboard Sensor and you set it up like this for example on a cube and add some things around it, so you'll be able to see motion:
Keyboard > And > Motion

Keyboard: set it for the up arrow
And: leave it as per default
Motion: give it an x location value of about 0.1 (1 tends to be a bit fast)

And ta-da, the cube will move! Incredible how easy and straight forward games can be!

On the Keyboard sensor, it's important to note the following:
 > When you click on the blank button next to "Key:", you simply press the key you want activated with that sensor.
 > If you click on "All Keys", it's the equivalent of "Press any key to continue" and all key combinations are muted.
 > If you activated a simple a key press, you will see that the key can sometimes overreact. To overcome this, simply enable Tap
 > For key combinations, you use the modifier options. Remember the order in which you press them don't matter, as long as you don't affect anything else when you press it, haha. They do cross, so if you want to make sure they don't clash, you can add another sensor called Actuator to tell the game it's fine to react or not to react when pressing certain keys.
 > If you want a text input in your game, like say a name or whatever, you use Log Toggle and Target. Your Log Toggle tells the game property that it should take text. It will even add text to a boolean value. The Target property can be the same and it is the Game Property, a string, that will receive the text.

Now, in order to add text like the above, simply add a keyboard sensor and a String game property and add the property to both the toggle and target slots (no key assignment needed). To see what you are typing, assign the text property to a text object's text property and ta-da, real-time writing in BGE. I'm yet to test more advanced than just typing, but it's very cool!

And that is it for this QBT. Keep working, practicing, doing tests, etc and soon you'll be able to make something spectacular, if you can't already!

Have a fantastic day!!

Thank YOU!!!!!!

In : Quick Blog Tutorial 


Tags: jesus  quick  blog  tutorial  blender  game  engine  keyboard  control  text  add 
Social
(+27) 073 104 2834   |   marius.oberholster@gmail.com   |   Contact

Make a free website with Yola