Blog! Team! Forum! About Apricot! Press! Gallery! Development! Yo Frankie! Apricot Open Game Project mee!
Jun 4

Camera and movement system

icon1 darek | icon2 Uncategorized | icon4 06 4th, 2008

From Amir, one of the Crystal Space developer working on camera and movement system improvements:

No it’s not the new Hollywood blockbuster, it’s my test application for developing the camera and character movement controller! Because it takes a while to update python bindings when developing C++ code, I use this interim solution while doing heavy development.First you see character walking in and out of the camera. There is a slight spring, but only within a certain range of the relaxed position. You can visualise the camera as having a hard pole with a spring attached to the player. When the player walks into the camera, the spring becomes depressed and the camera will start to move backwards. If you move beyond the spring then you will just push the camera. So we calculate the desired forward movement to reach the player within our range for the camera using the equations:

cos (x) = camera_direction . camera_to_player
move = distance * cos (x)
=> move = distance * (camera_direction . camera_to_player) – forward_position_offset
Then you next see tilting the camera up and down. There is no standard or universal behaviour in games really for tilting so I took a bit of creative license here. Annoying the player with too many controls for just a camera can just be well, annoying. So how to incorporate the zoom? Well this looks like a nice solution. We actually describe the ‘hard-pole’ positional offset of the camera we just described as an elevation angle from the ground and a distance and can use the normal circle equations to find the camera position for tilting. For this zooming effect I just make the distance proportional to the elevation angle.

Then it’s collision detection when you walk into the wall. This more than anything causes lots of pain. Some games don’t even let you pan into the wall 🙂 cheaters. Not only is the collision detection dependent on a calculation in one place, but another calculation is dependent on the collision detection in another place. Throw in 2 or 3 more of these cases and then you have dependency nightmares. Then panning into walls at large perpendicular angles when you first touch the wall when panning, usually means that the camera is oriented halfway between nothingness and the world. Therefore you need to offset the camera from the wall. But if you get in close, then this offset will cause the camera to flip on the otherside of the player and so you need to linearly decrease this. Then you also need a vertical offset for the camera, above the players collision box if the target is inside the player… and you need to interpolate this value too. Coming out of the zoomed-iness the camera will jump, so you must interpolate the zooming out also. This needs some more work, but well everything interferes with each other 🙂

To finish off there’s some preliminary character movement demonstration. I haven’t worked too much on this yet so it’s a bit rough. TODO: Fix the jumping of the camera between movement modes. 🙂 The first mode is when you go into fighting mode. No enemy is around so you just strafe around. Suddenly an enemy enters the view! The camera locks onto the target and you move around the enemy, rolling and dodging and doing attacks. The player movement needs work though yet, like smoother turning when moving diagonal after moving straight. Straight to straight movement should be fast though we think.

Any suggestions for you preferences? What do you think of mouse control for the camera? This is popular but I sometimes get annoyed when I’m accidentally knocking the camera. Below is the written document for player movement.

From Apricot:

Beside of developing in the Blender Institute we working remotely with other Crystal Space developers, they made a lot of new amazing improvements like new animation system, smoother collisions, new logic system, also camera, movement system and many other things. So without their work it would be impossible to release an industry-quality game. Cheers guys !

17 Responses

  1. fruhp on

    i really-really liked how the camera didnt go into the wall.
    excellent work!

  2. venomgfx on


    btw, Amir (the author of this blogpost and camera system) is most known as Genjix in the forums.

    so grab him a beer if you see him around 🙂

  3. Skun on

    Hello there! I love this project and am working with Blender for years now. I have been trying to get gameblender working with my content but i am a total noob with python / logic bricks. My FPS drops like mad when any animation is applied… (parented armatures to invis-cubes for movement + many actions = broken keyboards)

    I have been working a lot with how best to use camera movement. I know that mouse camera movement is popular with creators, but i’m not so sure its popular with players, …sharpshooting highly accurate games like FPS, it is necessary, but my 2 cents for adventure type games is that entire movement and camera position is better left to keyboard alone. IE Player movement with numpad keys then use your thumb on the arrow keys for camera positioning. or WASD move and arrow again for camera. this way you dont have to jump from keyboard to mouse and back while fighting, escaping and maneuvering. Try it out i think it works great.

    Anyway, i hope dearly that this game is successful, i have already pre-ordered and I am looking forward to playing this asap, then after ive had my fill, swapping your content out for mine and leaving the flying buttresses of intense code ect “as is”. lol open source rulz’s!

    HOpe these words find you all in good spirits, keep up the great work!


  4. dusty on

    Nice job! Pat on the back!

  5. Francisco Ortiz on

    Aaaaaa the camera!

    Does anybody played the new GTA?
    Is it only 360 or PS3 right?

    Maybe you should recomend a standard joystick model for Apricot… I don’t know :I

    What do you guys are thinking about this videogame plataforms “strike back”? I mean… What is your strategy about this: PCs X “closed PCs”?

  6. J on

    I prefer 2 analog joy sticks. I have no problem with a mouse, but WASD is horrible for walking around.

  7. James H on

    The camera system used in a project I am working on has designer-controlled camera volumes(player control based only on avatar position) which follow x/z/interpolation curves. So as you walk through a room the camera can swing in one direction to follow the curve. Player movement is kept camera-relative. It needs a lot of tuning to avoid 180s and wall penetration though.

    My ideal camera would be a pathfinding camera – reusing the collision to get the appropriate angle and distance.

  8. jinchoung on


    glad you guys are working on and thinking about 3rd person camera for 3dgame! it’s one of the hardest things in games! there are SOOOOOOOOOO many games where the biggest complaint is the camera! this is probably not going for a heretic2/max payne system but that’s probably the easiest solution – basically, fps controls in 3rd person…. but that makes it feel like a different kind of game. for a platformer/consoletype, your kind of camera is probably what is best…. wow, i hope you guys take the opportunity and try to show the fat cats how it’s done! seriously, nobody had a perfect 3rd person camera and it really gives you an opportunity to make a name for yourself! good luck!

  9. MrE on

    Good to see that there is time put into proper camera behaviour.
    A lot of comercialgames are simply ruined because the camera behaves like crazy.
    Strange to see that, with all those third person games around, there’s still no universal way to rig a camera in a game.

    Isn’t it possible to use a third person camera and switch to first person when the camera collides with an object?
    Or am i saying something really stupid?

  10. Epsilorn on

    I’ve a question: in the last part of the video, the character goes into a red light coming from the other room, and I see it turning red, is that lightmapping or is it hardware light?

  11. MistaED on

    I would really like the option of having total mouse movement of the camera, or at least have the option! I really really really hate automatic cameras 🙂

  12. jin choung on

    going into first person when you hit a problem isn’t stupid but it could be pretty jarring – having the computer decide when you’re in 3rd person and when in 1st…. also, a game of this kind depends on being able to see your character…. i think autocamera is a good decision but as i said, it needs to be well implemented… again, TONS of games on the market to show you how it SHOULD NOT be done! there should probably be a camera control too for when the player really wants the camera to go somewhere else (in console games, this is usually because the automatic camera is looking at a wall or something instead of the enemies)… oh, that’s another thing, the camera should also be giving consideration to where ENEMIES ARE! camera should try to look at you and your immediate enemies. that’s a big complaint – enemies are just off screen shooting you and you can’t do jack crap about it!

  13. MrE on

    I see your point about the auto first person.
    An alternative would be to bind a key to go to 1st person when the player wants it.

    Another question is:
    Will the camera be tracking the apricot ammunition when shot from the Apricot shooting bazooka (like the missile in UT)? or will the camera just stay in third person?

  14. MistaED on

    Forgot to say the current implementation looks great!

    What I meant by total mouse control was not being first-person but pretty much exactly what you’ve got there except the camera doesn’t work out things for you, you move the camera yourself. A very good example is splinter cell, and they got around the binary nature of WASD by using the scroll wheel as a speed tempo changer, but that would mean item changing would have to be another 2 keys probably. Good luck with it 🙂

  15. bmud on

    I did most of my development time with Ozone Force on the camera and controls system. It’s tough. The wall collisions are fancy, but what you should really try is seeing how it will behave when the character moves at a variety of angles and speeds: ie, throw in some analog joystick support. Sometimes a joystick will make a certain camera system a dozen times better, and other times it will find the strangest behaviors.

  16. jinchoung on

    i wonder what good psuedo code for a third person camera would be? what’s the best logic? i mean there must be a reason why even big budget games like ninja gaiden2 still can’t nail it….

  17. ilo on

    hi ill make a climbing tree thing for you but in retern i want a jump tutorial useing a model of frankie. thanks