Episode: 495
Title: HPR0495: Gary Whiton talks about the Blender Game Engine
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr0495/hpr0495.mp3
Transcribed: 2025-10-07 21:45:14

---

.
Hi everyone, right? Thank you. Right, I'm Gary, more of a designer than a programmer
just to kind of make it clear. So when you're asking questions later on, anything
script-based, like computer language based, you'll get a very blank expression. So I'm
just going to do a very basic intro to Blender 3D, which I've sort of recently started
learning the game engine side of it. And the weird thing I found where it was, I mean,
I don't know whose experience Blender showed here, but I found that everything up to the
game engine was quite hard to learn, the interface, textures, animation that a lot of it
was very tricky to learn. But once I got onto the actual game engine part of it, it
was relatively straightforward. So I'm going to show you a game that I've kind of been
putting together in the last few days. And then basically just go through how I
put it together. So with any luck, make it sort of full screen-ish. This isn't the
best game in the world, but essentially this is really just to kind of show you
what you could put together comparatively quickly without actually needing to have
a load of program experience or sort of that sort of thing. So bear with me.
Now the way robot there basically is, oh, if I actually fell off here, I was going to
design it so that it tells you it says you lose or something like that, but I hadn't got
it. So I'm going to make it to the end of this very long game here. And because I
haven't actually programmed the win thing either, it kind of goes a bit bear-shaped.
Okay, so that's the game. Obviously not amazing. I'll show you what happens if you fall
off as well. Now obviously this is pretty sort of reasonably simple. If you actually
have more time and know what you're doing, you can produce something a lot better than
this. And once you kind of get to the limits of what you can do in the game, it
allows you to use Python scripts to do much more kind of complex stuff, which I'm starting
to look at. And it's obviously scriptings never going to be totally straight forward, especially
if you're not from a programming background. But with that in mind, it looks reasonably
accessible. And there's a lot of tutorials and things that you can look at on the net, especially
Blender's own website. And having had a look at that, it seems quite accessible.
Okay, so what I'm going to do is, what I've just shown you there, I'm going to take out
all the kind of, not programming, but all the kind of camera moves, the movements of the
model and everything else and start it from the beginning. So all I've got is a set and
no actual interaction. So what I have to do first is select the model here. Now, first
I've got to open the scene where it's not already done. That'd be a better idea. Right,
okay, so I select the model. And this little icon here, I don't know if you can see it,
yeah, that way I can there. That's the game logic icon. So when you want to kind of make
something interactive in the game, you simply click on that panel and then that takes you
to where you do it. So what you've got here are sensors, controllers, and actually
controllers. They're known as logic bricks and you basically link one thing to another
to another. So I'm once you've done that, so I'll just show you actually, if I click on
sensors, I'll add one there. Now, the wee characters called Robo, yeah, so if I did a sensor,
I'm going to set it to keyboard, if I can find it, there we are. Okay, and I'll be honest,
I don't know what a load of these things do, target log, no idea. All I know is you click
on that, the key thing there, press a key, and that's it, set up, link it up to the controller,
and then create an actuator, which is, actuators are basically what does the thing.
So this is set to motion at the moment. You've got a load of other things that do crazy stuff,
some of which I understand and some don't. Sound effects, cameras, constraints, that kind
of thing. But I'm going to use motion and I'm going to set it to move forward. Now, I know
from previous experience, it's this one here on the Y axis. Essentially, with this stuff,
the way I learnt was just by trying things out, getting it wrong, but seeing what happens,
and you know, if you've got a more mathematical approach, then you'll do this a whole lot faster.
Okay, so hopefully when I press P, which switches the program to game mode, basically,
you can try out the game within the program, you don't need to load up or anything of any
compiling without nonsense, you just basically press P and it goes straight into the game thing.
Now, let's see, oh, I've also pressed the right button. There we are. So I've got the
character moving forward. The camera doesn't follow them because I've taken that out of it.
Okay, so I'm going to make and go away a bit faster.
There we go. That's a wee bit more like it. Okay, so now I'm going to add a couple more
to make it so that you can actually turn left and right.
There you go. So, okay, I'm going from experience. I know that's
a single velocity right, so I'll mean this. It's always quite fun when you get the numbers wrong
and things spin around manically. Okay, and I should set this to be keyboard and the left key.
Okay, let's try that. Okay, so I've got that wrong. I need to put, basically,
make the number I've put in here at the opposite. So instead of minus 0.5,
it should be just 0.5. Okay, there we are. Okay, maybe make it a bit faster.
So I'm just going to do the same for the right hand side. Now obviously this
starts to get, starts to look quite complicated, but you can actually sort of hide
all these numbers and things so that you can see better what you're doing.
Right, set that to keyboard and right hand.
Okay, at the side of these numbers you'll notice there's a little L there.
Basically, what's that, what that's for is whether the movement that you're
applying is applied locally or globally, which in real terms means if you want
something to sort of go left, is it the characters left or is it left in terms of
north, south, east, west kind of thing. So you can essentially just click that
off and on. A good example when you might use that is if you're wanting a ball
to roll and then you're wanting it to go forward. So if you set it to local,
what will happen is you'll have it spinning around and it'll keep trying to go
forward in whichever direction it's rolling in, if that makes sense.
So if you set it to global then it'll just go forward in whatever direction you
said. So it'll keep rolling and go in that direction.
Okay, let's see if this works. I think I want that to be local.
Okay. So that's kind of working. The rotation is too slow.
So I'm going to speed it up to maybe minus five and five.
There we are. So as you can see, I mean it doesn't take ages to get something like
that working. I mean, obviously if it's the first time you've played about
with it, you'll need to take a wee bit of time to get used to the layout.
But as far as kind of putting games together is concerned, I can't see how it can
get much simpler, really. There's lots of other things. I mean, instead of
setting this to keyboard, let's say the forward thing, I could open that up
again. Instead of keyboard, I could have it to always.
So without touching anything, it's always going to move forward.
If you want to make life a little bit more exciting.
Oh, that's interesting. I think I maybe...
I can't have a problem here. No. That's interesting.
I actually don't know how it's doing.
Maybe. I didn't know.
That's just the left and right controls are swapped over. That's interesting.
You've got physics settings and stuff like that on it as well.
I'm just going to pretend that that's all OK.
And what I'm going to try and do now is to set the camera to follow the character.
Now, anyone who's played a lot of 3D games will know that or tried to make 3D games will
know how hellish it is to try and get a decent camera working.
And it's no exception here. It's just difficult.
But to get a camera doing something like what you want, again, isn't too bad.
So I'm just linking the sensor to the controller to the actual.
And this middle bit here, the controller, you can use that to sort of control how certain actions happen.
When you start to get more complex stuff, say you want two things to happen before an explosion goes off or something like that.
Then I think that's what the controller is for.
You can add lots of things to that controller and it won't do anything until it gets all these different parameters happening.
But I mean, to be honest, I've not really played about with that much at all.
OK, so the camera.
Now, I don't want it to move this time.
So I'm going to try and set it to actually follow the, follow the wee robot guy.
So I set it to camera.
And this bit here will be that's the object you want it to follow.
So the object is robo.
What's quite nice about this is if you're trying to link something like the moment I'm trying to like this camera to the object.
If the object doesn't exist or if it's got a different name, it won't let you put that name in it.
It'll just remove it instantly so you know right away that you've typed something in wrong.
OK.
Let's see if I can get these numbers right.
If I get these numbers wrong, then it's going to spin about all over the place.
Now, I don't totally understand what these are doing.
I think what this min is, min and max is the kind of minimum distance and maximum distance that the camera follows the object.
But I've not totally got to grips with it.
So I'm just guessing it.
I'm just actually the height that the camera floats above the model.
So if you want to have a really low angle, you just set it to something like I don't have two.
Let's give that a try.
OK, there we are.
That's a nice low angle for me.
Let's see if the logic, if the physics is still not working.
OK.
So set the height a bit more.
Right, there we are.
That's quite strange.
I don't know how that's working.
There we go.
So I mean, as you can see, I mean, this hasn't taken me very long.
Obviously, it's not very good, but it just shows how kind of quick you can put something together.
And if you actually spend the time, you could get something a lot better looking than this.
As soon as I've got through that stuff, I'm going to see if I can show you one or two other bits and pieces I've done.
There we are.
There's another neat function that the engine can do, which I'll hopefully get time to show you as well.
But first of all, this is basically just me trying to do a kind of underwater scene.
With little bubbles floating up from sort of down below.
Essentially, how that's working is that I've got two kind of invisible boxes at the bottom.
And I've set it up so that they move randomly, sort of, along two different axes.
So they go left and right, kind of like that.
And then they go up and down like that.
And every half second or so, they create a bubble.
And the bubbles got its own sort of, its own logic, which tells it to just constantly float up.
And it's got a kind of random thing to make the bubbles kind of wobble about a wee bit.
And again, I mean, that was reasonably straightforward to do.
Once you start playing about it, you go, oh, that does that.
Well, maybe I can add this or use it for that.
And a lot of the time it does actually work straight away.
And again, essentially what I've done with this is applied the same kind of controls that I used for the wee robot.
And just apply them to the camera instead, so that you can kind of fly around.
You can also do lots of other things like say these bubbles, say you wanted to change them to something else.
Then there's a function for that, which is reasonably straightforward.
I'm honestly at the, to change them in the wee skulls.
But I can't remember what Philo saved it as, so I can't show you that.
And then the other, the one complicated thing in all this is the water there.
Which is, this is a video texture.
So what I've done is basically I've got a video of just water and then applied it onto this sort of plane.
Now, the game engine itself doesn't have a function that allows you to do that easily.
And this is using a script, which I downloaded because I wouldn't have a clue how to do it myself.
And I'll maybe just show that to you.
Basically, scripts allow you to do much more complex things.
Because essentially, as you've seen, it's kind of fairly easy to kind of connect things up and make stuff work.
But once you start doing anything moderately complicated, you'll just get loads and loads of these logic-rich things.
So a script would allow you to kind of make it a lot simpler.
Now, here we are.
So what happens here is the script, the way you actually get a script to work is you link up the same.
So, as you would normally do, and then instead of going to a controller and then an actuator,
you actually just go to this script here, Python.
Yeah, that's such to get complicated.
Anyway, I think that's pretty much everything.
So has anyone got any questions that aren't too complicated?
Yes, well, pretty much all the main ones, anyway.
I mean, this is running on Mac, it runs on Linux, and Windows.
It's updated quite fairly regularly.
The next one they're doing, the next update apparently, is to actually make it the interface a bit easier to use.
So if you have used Blender, you'll know what a godsend that'll be.
Anything else?
How long have you been using Blender?
Blender, isn't the program I've been using for must be about a couple of years?
The game engine I've been playing about with for a couple of months.
And the thing was that because everything else was really hard to learn,
because I was using it for animation originally, everything else was really hard to learn.
I thought, there's no way I'm going to learn the game engine.
It's just going to be too complicated.
I mean, you know, the animation was hard, so just imagine how hellish the game will be.
But what turned me around was seeing there was a tutorial on, I think it's on the Blender website.
And it showed you how to create a table and a bunch of objects
and have a ball rolling about knocking the objects.
And so the physics and everything were already sorted out.
And to do that, I mean, OK, it's reasonably simple thing.
But to do it, they had it on just one sheet of A4.
It's not too bad.
It's not going to take ages to learn.
And so from that point I started playing around.
And a lot of it really is quite straightforward.
The important thing is just that you just experiment, try things out.
You know, just don't be afraid to kind of, you know, connect things up to it.
You don't quite understand and see what happens.
Because surprisingly, a lot of the things actually do what you think they're going to do.
So given example of how it can go wrong, I had to use it on a course once.
I think I've told you this, but I had to do an animation of the moon going around the Earth.
But I did a slightly wrong flick of the mouse and it actually turned out that it was the moon coming out of the Earth going around and smashing it into the Earth.
So anyway, yeah, that's pretty much it.
Any in this mess? Any more questions?
Thank you for listening to Hack Republic Radio.
HPR is sponsored by Carol.net.
So head on over to CARO.NAT for all of her TV.
Thanks for watching.
