0
$\begingroup$

In Blender, as I'm sure everyone knows, there is a game engine and I've been neglecting it. I don't have any big plans for it, just to see what it can do.


But there's two ways two ways I can do this:
1. Python or
2.Logic Bricks
I don't know Python, but I was wondering, does Python have any more capabilities than the logic bricks? Would I be limiting myself by using the logic bricks? Are all of Pythons(and really all coding languages) logic represented in three drop-down lists of Sensors, Actuator, and Controllers?

Sorta Related Question

Which is more efficient for performing simple actions, Python, or Logic bricks?

$\endgroup$
  • 1
    $\begingroup$ You can do quite a bit with logic bricks, but if you want to do really well, go for python in the long run. $\endgroup$ – X-27 the fluffy unicorn Sep 6 '16 at 0:44
  • $\begingroup$ @X-27 So, does that mean python can do more than the logic bricks? $\endgroup$ – Unnamed Sentient Being Sep 6 '16 at 3:47
4
$\begingroup$

Yes a python script can do more than logic bricks. Most likely you will use both.

There are three types of logic bricks - sensors, controllers and actuators. Sensors are used to input data to the game engine such as keyboard and joystick or internal data like collisions that you may want to react to. Actuators perform actions, they may start an animation or they may alter a property. Controllers then provide a connection between the sensors and actuators.

Controllers are where python comes in, a python controller allows you more control between the input and the action. In the simplest form you may use a python controller that does a test before starting an actuator or maybe dynamically adjusts a sensors properties and at the other end of the scale you can go all the way and just use one python controller which is connected to an always sensor that looks at all of the input and alters all game data itself.

So start by using logic bricks to get your game running and then when you get stuck with something that just doesn't work the way you want it to, create a python controller for it.

$\endgroup$
  • $\begingroup$ Good answer, but you might want to include that python isn't organized into sensors, controllers, and actuators; and that the OP would be limiting himself by not learning python (two of his questions). $\endgroup$ – JakeD Sep 6 '16 at 11:08
  • $\begingroup$ Could you give an example of something that python can do but logic bricks cant? $\endgroup$ – Unnamed Sentient Being Sep 11 '16 at 19:11
4
$\begingroup$

The BGE's logic (describing behavior within your game) is based on SCA (sensors-controllers-actuators).

It is an event system that let you describe WHEN happens WHAT.

It will be configured via logic bricks. The build-in bricks allow easy configuration of static behavior. The majority of operations can be done with build-in logic bricks.

There is still a huge amount of logic that requires dynamic processing (e.g. find the closest object in a set of several objects). This is very hard with the build-in logic bricks. Therefore you can create your own custom bricks. You describe the behavior with Python. This allows you to use the full power of this programming language (but you need to learn it first).

But there's two ways two ways I can do this:

  1. Python or

  2. Logic Bricks

Knowing the facts from above will hopefully show you - there are no two ways. It is the same way. You can exchange some of the two options (e.g. you can create a custom brick to do what build-in bricks already do and you can use several build-in bricks to do what Python code can do). Quite a lot can't be interchanged and you have to use Python or the Logic bricks unless you choose a complete different design.

Are all of Pythons(and really all coding languages) logic represented in three drop-down lists of Sensors, Actuator, and Controllers?

For unknown reason you can only create custom controllers. This means you need to let the controller act as actuator and/or sensor (inefficient). It can act as all three brick types at the same time.

Be aware it is still a controller. It will be executed with all other controllers (after the sensor evaluation and before the actuator run).

Remarks:

Some people tend to avoid logic bricks and try to implement an own event system. This is not recommended. When you are not happy with the framework the game engine provides you might better change to a game engine that fits your needs better. The BGE is no "script only" engine, nor a "configuration only" one.

My recommendation:

  • Learn to use the bricks
  • Learn to use Python
  • Learn to judge when to use what (and use what you think is correct)

I hope it helps

$\endgroup$
1
$\begingroup$

Python is itself powerful in BGE, and for advanced developer, Python opens a window to a even bigger world of possibility.

What I did was to program all computationally intensive and complicated communication functions in C++, using Boost.Python as a [C++,Python] interface. Compile the code as a DLL (dynamically link library), and use python in BGE to import and interface with the DLL functions. The DLL can have access to any objects the BGE python have access to.

This approach really allows you to do anything you can imagine. I was managed to run intensive math crunching, serial communication and udp broadcasting in BGE with this approach.

$\endgroup$
1
$\begingroup$

BGE offers several advantages over other game engines (Unreal, Unity, etc) because it allows you to build assets that the other game engines can't match. That said, BGE suffers a huge negative based on the fact that it doesn't provide for a rich development environment. The logic bricks are great for beginners and there's nothing wrong with supporting them and making them even better but, in the end, an original game is going to take a large amount of custom work (inventory, UI, configurable controls, etc) that the logic bricks do not support without a nightmare of nodes and lines. A programming language, on the other hand, does these things with ease. Blender should absolutely allow for a full Python control system and offer logic bricks as a streamlined solution built on top of that system. Why? Because, without full scripting support you can't, for instance, build the ultimate RPG control camera that allows you to simply attach it to the cube in your scene. Instead, you have to look at the developer's code and figure out which sensors to hook up and what to call them and you have to do this for every object that could appear in your scene. That is in violation of the liskov substitution principal and, frankly, a rookie mistake. What we need is a way to attach fully functional behavior to any object, along with configurable parameters to control that functionality. Secondly, we need a fully featured IDE to develop that code in. Sadly, neither is possible in the BGE without extreme effort.

$\endgroup$
  • $\begingroup$ Is this an answer to the question (logic bricks vs python) or a rant at the BGE? $\endgroup$ – David Nov 3 '16 at 13:06
0
$\begingroup$

Python can do a lot of things that bricks cannot...some fancy screen space AO for example, and bricks can turn into a tangled mess the more complex the game, the more useful python becomes. I personally try to avoid the bricks as much as possible, unless 3-4 bricks < the lines of code required to accomplish a task... e.g. if I just want to activate an animation of a sign based on the distance of the player...I will use bricks....

if I want to dynamically make the sign sway in the wind, I will use python...less lines of code versus the amount of bricks and additional objects may be needed with their own bricks.

I really do not care for the bricks tbh, but they do have some nice functionality for creating spawners or simple tracking of objects..but some simple math does the same things...

I fully recommend you look for resources online for python and vector math bricks are fine for mario, but for skyrim you need python.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.