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 

"For I testify unto every man that heareth the words of the prophecy of this book, If any man shall add unto these things, God shall add unto him the plagues that are written in this book:
And if any man shall take away from the words of the book of this prophecy, God shall take away his part out of the book of life, and out of the holy city, and from the things which are written in this book.
He which testifieth these things saith, Surely I come quickly. Amen. Even so, come, Lord Jesus.
The grace of our Lord Jesus Christ be with you all. Amen."
Revelation 22:18-21

"Add thou not unto his words, lest he reprove thee, and thou be found a liar."
Proverbs 30:6

King James Version, Public Domain

Ultimate Glory

I give glory to, acknowledge and remember God for this website. He enabled me to do all this and this website belongs to Him. Thank You!


Make a free website with Yola