In this tutorial, you will learn how to move your character around while having the camera follow behind. Do not pay attention to the graphics, as I am not showing how to make the graphics of a game, just merely showing you the basic concept. Enough babbling, and onward to the tutorial…
Step #1: Start Blender
Now start blender by selecting the icon. You should see something similar to this:
Step #2: Creating Our Scene
As you can see, we have just a cube in the middle of the stage. Select (right-click) and delete it. Now insert a plane, a sphere, and an empty. Select the camera, hold shift, and select the empty. Press Ctrl + P to make the empty a parent to the camera. Now, select the empty, hold shift, and select the sphere. Again press Ctrl+P. This will set the character as the parent of the empty. Now that you have all of the parenting set, select the sphere, and move it up on the Z-axis so that it is a little higher than the plane. You should now have something that looks like this:
Step #3: Correcting the camera
If you run the game at this point from the camera view, you would notice that the ball moves in a diagonal direction. This is because the default camera position is facing the center from a 45° angle. You must move the camera behind the object, and rotate it so that it is facing the object. Here is a top-view of the corrected scene. It should look something like this:
Step #4: The Logic Panel
Usually when creating a game, you must put some kind of code in telling the character where to go. For our game here, our character is nothing more than a sphere. Now, I said earlier that there is no programming necessary for crating this game. Everything is done in the logic panel. To access this panel, press F4. Make sure you have the sphere selected. You should see something like this:
Step #5: Physics & Collision Detection
We need to make it so that gravity affects the character and. Left-click the “Actor” button, then click the “Dynamic” button. Now, Click Bounds, then change the collision type to “Convex Hull Prototype”.
Let me explain a little about what you have just done before we continue. When you selected Actor, you have established collision with the object. This means that when another actor collides with it, the other object will be stopped, although this object will not move when there is a collision, and will not be affected by gravity. To do this, we must make the actor dynamic, and this is why we selected dynamic. It is now affected by gravity, and will move when hitting other moving dynamic actors.
There are so many different models/shapes you can have as an actor. The default collision type is box. This collision type isn’t good if you have a complex object. For example, you have a hilly landscape. If you leave the default collision type, then your character will walk across the top of the hills. The character will not walk down the dips. There are six different types in Blender:
- Box – This is the default. An invisible box surrounds the entire object.
- Sphere – An invisible sphere is drawn around the object
- Cylinder – An invisible cylinder is drawn around the entire object.
- Cone – An invisible cone is drawn around the entire object.
- Convex Hull Polytype – doesn’t have a set shape. It wraps to any convex object.
- Static Triangle Mesh – for triangle meshes? (I don’t know much about this one. Please fill me in if you know. I will cite you as a reference)
Step #6: Creating the Movement
Now, we must make the character move forward, backward, turn left, and turn right. To do this, we must first click “Add” for the sensors, controllers, and actuators. Add four for each one. Connect them together (connect 1 to 1, 2 to 2, and so on), by left-clicking and dragging from one connection to the other (the circles). In the end it should look something like this (note: the blue box shows changes that should be made, and the yellow lines are new connections):
Step #7: Testing Your Game
Make the 3D viewport as big as you can make it, and place your cursor in the viewport. Press P to begin the game. Try using the arrow keys to move your character around, trying not to fall off the edge. To end the game, press the Esc key. If everything works, then you have reached success, and if not, then you need to go back and try to troubleshoot your problem.
Step #8: Giving Feedback
Now that you have finished the tutorial, please give me some feedback. Tell me whether this was useful, if I had faulty information, if I have skipped a step, or whatever. I will also accept requests for different tutorials dealing with GameBlender.
I hope you have the basic idea. I encourage you to mess with some of the values with the dynamics, and the movement node, and see what the effects are. I would tell you, but I have learned that discovering things for yourself is more effective than having the answers given to you.