You must learn programming, and learn python

If you want to get serious with the blender game engine you must get your hands dirty with python scripting. Read my previous post (add object actuator and lights) for an example.

Some basic and important features of the game engine are only accessible with python. Logic bricks are just for the basic setup.

I’m preparing some tutorials documenting the various problems that I managed to solve using python scripting. The only thing that is slowing me to do that is my poor english. But I hope that they’ll help anyway.

ciacio

Here it is:

http://www.poeticstudios.com/blender1.htm

More coming soon.
Comments appreciated.

ciacio

Hmm, interesting. Didn’t know you could do that. Then again never really found a need so far for an added object that needed to be affected by the light.

Your english isn’t bad. The tutorial is pretty much understandable. Hmm, your english is otherwise perfect in this post except for that sentence where you said your english is poor.

The only thing that is slowing me to do that is my poor english.

“to do that” , I was expecting you to say “down” instead. Don’t know but before it was some grammatical error I think.

Jason Lin

Don’t think about the ‘edit object actuator’ just for bullets or small object.

It can be used everytime you need to add a bunch of objects with fixed life: particles for smoke and other effects, and so on.

I lost almost a evening struggling with this problem, without help. I think it happened because the behaviour of this actuator has been changed in the last few versions of blender. Maybe in the earlier releases you could add objects taken from a visible and active layer.

By the way, thanks for your comments.
I’m planning to write tutorials documenting every interesting problem I’ll find playing with this exciting feauture (game engine) of this wonderful free software.

Thanks again,

ciacio

p.s. If you’ll find my tutorials useful, you can repay me by listening to my music at:
http://music.download.com/cesaremarilungo
and watch the video on my private site:
http://www.cesaremarilungo.com

what about a different layer on a different scene?
or multiple layers on a different scene?

:wink: Hmm, scabootssca brings up an interesting point. Does it work for multiple scenes?

owner.layer = 2
owner.layer = 3
owner.layer = 4
… and so on

%| I know the edit object actuator is useful for many things. I was only commenting that you don’t really see many things that need to be added have to be affected by a light source. But then again, it’s specific to each game.

Jason Lin

What if you want enemies to spawn in, or for framerate issues you want to only have the enemies appear when you are close to them? Add object actuator. This bug has been a problem for a long time, it’s nice to see it fixed. It would be a bit nicer to use if you could set it as a list of layers instead of a bitmask though.

goldentaiji: it’s a bitmask, which means its a binary number. So 3 isn’t really 3, in binary it would be 00000011. Counting from the right, the first layer has a 1 in the bitmask, and the second layer has a 1. The other layers have zeros . So layer = 3 actually means it works in layers 1 and 2.

Very glad to know that this problem now has a workaround, nice find ciacio.

There’s no need to do that.

My hint solves a problem for which I haven’t found any other solution, beacuse the ‘add object’ fuction needs that the object that you want to copy must reside in a hidden layer.

Otherwise you get an error on the console and the actuator doesn’t work.

Jason, be careful that the layer property is a bitmask, not an integer. It doesn’t mean that 3 is layer 3.

You have to think that every layer that you want to light with a lamp must be a binary ‘1’ and the others are ‘0’, from right to left.

So, for instance, if you have a lamp that you want to affect the first two layers you have to write:

my_lamp.layer = 3 (binary 11)

If you write:

my_lamp.layer = 4 (binary 100)

you’re setting your light to be visible in layer 3 only.

If you write:

my_lamp.layer = 5 (binary 101)

you’re affecting layer 1 and 3, and so on.

It doesn’t make sense to me to put your object on a different scene.

Anyway, I wanted to write this tutorial and I’m writing here to point out that you can’t just use the logic bricks. Sooner or later you have to code some python.

And I think that this is a good thing. Because in this way you can have more control. You can’t write a game, even a simple one, without a minimum of coding.

I also found that in the latest Blender you can import the other blender python modules (not related to the game engine). This is very interesting. Being able to do that you can do a lot of useful, sometimes crucial, things. Like writing your own physics tweaks, having more control on the objects movements.

I am also experimenting with creating meshes on the fly during the game, and editing them. Think about having a cloth that follows your character, or a flag moving with the wind, waves on your water, and so on. Such things are possible on commercial software like Macromedia Director (using the Shockwave 3d functions).

In the 2.33 release of blender, importing modules other than GameLogic gave an error on the console.

Are you interested in a tutorial on these topics?

Write to me.

ciacio

Well said saluk!

I were writing my post when you were submitting your. Sorry if I explain the bitflag thing once again.

About the enemies coming when they’re nearer, you can do LOD (level of detail) in blender using (and tweaking) the script in the blender game engine docs.

In short, you can use the replace mesh function in the same actuator (or better directly in python) to select different meshes with different detail based on the distance from the camera.

To measure the distance don’t use the pythagora theorem strictly, beacuse sqare root requires a lot of time to calculate. Just use the sum of the sqares, as the script in the blender game docs cleverly does.

ciacio

You can set a light to affect multiple layers from within Blender: select the light, hit M, then select the layers. Hold Shift to select multiple layers.

Very useful hints here. Thanks a lot, guys!

Wow, I didn’t know. I’ll update my tutorial. But I still prefer using a script. You don’t have any kind of visual feedback in the interface with your solution.

Do you have experimented with modifying meshes (their shape) during the game?

Thanks for the hint,

ciacio