Need Help with Rolling Ball and Camera Following .. :P

Hi, I’m working on my first game, a small maze-puzzle game but I’m having a heck of a time getting my camera to work right and how to set up my controls in the most efficient way.

I’ve searched elysiun a bunch of times and read every camera follow tutorial I could find and I also have the gamekit book, which I have looked through, but nothing really addresses my exact problem, so I thought I’d post it up here and hope someone can help!

My problem is, I have a rolling ball that you control with the arrow keys (globally) and I want a camera to follow it. If you’ve ever played Metroid Prime on GameCube, and you enter Morph Ball mode, I want to control my ball EXACTLY like that. The camera follows behind the ball, staying parallel to the ground no matter which direction the ball is facing. Also, the controls in Metroid seem to be based on the direction the camera is facing, not the ball.

I’ve tried parenting the camera to the ball, and it spins wildly with the ball’s local coords. I’ve tried the camera actuator, which is close, but the camera bounces around as it tries to stay behind the selected axis.

Here’s a screenshot of the scene (just 3D view), the coloroed boxes around the ball illustrate (in-game) where the local coords are pointing as the ball rolls.
When the controls are set to global coords, they work fine if the camera isn’t moving, once it is, you get disoriented with what direction is X,Y or Z. Setting them to local, well, that’s useless since the ball’s local coords change as the ball rolls around. Is there any way to set the controls to the direction the camera is facing, while having the camera follow the ball (turning around corners as the ball turns) the way I want (metroid-style)?

I’ve read alot about the GE but I haven’t seen any examples of anyone trying to build the same setup I have here. I’ve posted the .blend below if it helps.
BallMaze .blend

thanks, I hope someone can help figure this out so I can move on to building the rest of the game!!

hi i got the file to follow the ball but when it turns corners the controls almost reverse is that how metroid is? if so ill tell you the logic.
kinda strange and cool at the same time when the controls flip hard to control though.
i anylized and it when the ball rotates that screws up the controls axis thrown off hmmm… :o

hahahahha ahahahahahaha ok that file all you have to do to fix it is open it go to camera veiw numpad 0 then select the camera the hold shift and select the ball then press tab and select ONE vertex then press control and p same time click ok make vertex parent. bam your go!


Hey Agness, I was going to reply earlier, but I was busy tinkering with the tip you gave. I got it working somewhat. The vertex parenting didn’t work on the camera > ball, but I added an empty just above the ball, vertex parented it to the ball, then parented the camera to the empty. Next, I set the camera to rotate left and right on <- and -> key presses, so the camera follows the ball because you’re aiming it, not because it’s turning on its own.

The only (yay!) problem I’m having now, is that the controls get reversed when the ball (and camera) are facing in the negative Y axis. What I am trying to figure out, is how to set the ball’s controls to use the camera’s coordinate system, instead of its local coords or the global coords because neither of them will work correctly as the ball navigates through the maze.

I’ve linked to the updated .blend file HERE to illustrate the trouble I’m having. You’ll notice the controls get screwy after you make two right turns and (the camera) faces in the negative Y axis.

I’ve tried making an object in front of the ball, adding controls to that, and vertex parenting the ball to the object. When I do this, the ball ceases to roll or respond to physics. I need to figure out how to set the ball’s coords to match (or use) the camera’s coords. This would make control of the ball easy and make the game more fun to play.


Ok, I was reading the gamekit book and basically, what I probably need, is some kind of expression or python controller that determines which direction the camera’s Y (for example) is facing, and applies that to the ball then adds the positive force in that direction when the Up arrow key is pressed.
The ball really doesn’t need to turn, I don’t think, just move forward and backward, using the camera’s facing direction to determine which direction is “forward” and which is “backward”.

I hope that made some sense, because I told myself, “keep it simple, nothing too complex” and here I am, having a problem that seemingly no one has encoutered before.

Like I mentioned earlier, if you’ve played Metroid Prime and you’re the Morph Ball, you press up on the stick and it rolls forward, away from the camera, press left, it rolls left, press down, it rolls backward, toward the camera. I think I can figure out the rest of my game “features” once I can get this control issue solved.

I thought there might be some way to do this with python, but I haven’t used python before (except for tool scripts) in the game engine, so I wouldn’t know how to start writing a script nor how to apply it to my game thingy. What might be the best way to learn how to write scripts/commands that apply to game objects? Maybe that would help me figure this out.


hmmmm… whenever you spin around controls reverse. dont even have to go forward

just select camera then ball >tab select rear vertex cntrl p yes and it looks cool and works well you like?

just try it again it works for me very well by the way looks like katamary damacy

Add the camera actuator to the ball or ? I tried the camera actuator on the camera tracking the ball initially, but it didn’t work right, it mostly floated around going behind walls and stuff and the controls were still screwy.

The cam setup is fine the way it is now, it’s the ball controls reversing when you get on the other side of it that are causing the problem.

without python you cant use the setup you have and no just the vertex parenting it will perfect but you wont be aiming the ball
edit: python will track the coordinates but logic bricks are too stupid to do that

I just found a site with a really beginner python->game tutorial. I’m working through that to get a grip of python, hopefully to learn something and later solve my problem.

Here’s the site link ->


cool thx! :smiley:
if you ever need help with anything else uv mapping ipos animation private message me

Hi! I hope you don’t bother, but I’m currently working in a python solution for this problem of yours. I got it all nicely laid in my head, now I need to deal with blender’s getOrientation(). Basically, this script will let you have a metroid-like control, with camera changes, and almost-total script automation… Hope I get through the getOrientation() pitfall :wink:

(and yes, this little question has got me wondering and tinkering with blender! very fun!)

Awesome! I started following that tutorial I posted but I’m not sure how old it is. blender seemed to lag heavily when I ran the engine after typing the script. I am attempting to learn some python to get a better understanding of working with the game engine.

Thanks for helping out with this, I’d like to complete this game and make it decent quality. I don’t know much about sound either, so that’s going to be another hurdle to overcome.

I’ll be away for a couple days but I’d be interested to see if you’re able to figure this thing out. If so, could you comment the code, explaining how you did it and what the code does, so myself and others can learn from it?

thanks! I’m excited about this project again… I was getting a little discouraged because learning python to a level of understanding is a big investment to overcome this obstacle.


That ‘big lag’ is probably from something writing to the console. It could be errors in your script. Check the console and see what it says after getting that lag.

Hi, I’m back at home and was just wondering if anyone has been able to find a way to get this working. I’ve been working on it myself, trying different parenting/camera actuator combinations, but nothing so far. I was also playing Metroid again earlier, studying how the ball and camera move in relation to the camera. There’s a slight lag on the camera what you press left or right on the analog stick, which means that the camera is tracking something in the scene, maybe a hidden object.
Somehow the ball is using a “View” type of coordinate system, either that or the camera’s. What about getting the 3D View’s coordinates? Would that be possible, then apply that to the ball?
The rolling of the ball confuses the directions when using Local, and as stated earlier, using Global get reversed once the ball is moving in ANY negative axis. Wish I had something to report, but sadly, only more questions.


no tracking you have a camera actuator and you add “lag” by moveing the time button :o

:slight_smile: I wasn’t asking FOR lag, just describing the behavior I saw in Metroid.
I’ve been scouring the forum for anything that somewhat relates to my problem. I’ve found a coulpe vaguley similar posts but nothing that’s right on.

Here are two posts
the first one is talking about screen coords and the other is talking about setting a dynamic object’s X + Y force in the direction of the camera, which, is the closest I’ve seen to what I’m looking for. There’s a couple chunks of python posted near the bottom, but I’m not sure what to do with them since I’m just starting python myself.


Gendo, just want to report my progress…
I’m working my way through python… and it’s going well I must say… I got the ball movement ALMOST done, yes, including that nice effect that as the ball picks up speed it slowly aligns in that direction… And don’t worry my python scripts are 25% script and 75% documentation ;).

About the camera controls? I’m about to start to work on the 2d-3d switch (yes, from normal mode to labyrinth mode). Although I got it all figured it out and in a couple of days (if not tomorrow) I’ll get some kind of demo to share…

YOU GOT ME DUSTING MY TRIGONOMETRY KNOWLEDGE dude! But it’s definetively interesting, I also took the liberty of downloading dreamkatana’s ultimate blender 2.37b… :wink:

And the camera lag? Thanks for pointing that out, luckily, my current setup allows me to add that camera delay, and yes, tracking an invisible object :wink: (that actually I use as an essential part of the ball’s movement).

Anyway, keep blending!

I read the posts you linked to…
the first one, why do you need it? There’s a finished script that does that, done by DanyAlejand… You should search for it… I don’t know why you need it though…
About the second post, hmmm, never knew you could use the orientation matrix like that… :-?

Hi Fred_Pyo, thanks for working on this! I’m really looking forward to what you’ve come up with.
About the posts I added, they are just some links I thought might be useful since there’s a bit of similarity to my problem, I don’t need the script in the first post, it just seemed to be in the ballpark of the problem.
Also, the camera doesn’t need to lag, it’s just something I noticed in Metroid while trying to figure out how they may have set up the control system.

I’m looking forward to your 75% documentation so maybe I can (using python docs) learn how you made it work, not just copy and paste your script.

After reading your post I’m really excited to get further in building the game. Getting the controls just right are (I believe) a really important piece in making any game fun to play.

p.s. Would you be interested in helping in the game if I run into bumps I can’t figure out on my own? I’m aiming for simple and fun so hopefully it would be fun to work and to play!