3rd Person Camera
3rd Person Camera
Well I was bored at school today so I decided to write a basic 3rd person camera, using Star Wars Galaxies style controls. For those who don't know what the control is like, basically there is a small box area in the center of the screen where the mouse is free to move. If it moves outside of this box the camera rotates around the character.
You can download the project here: http://members.rogers.com/jamiegoodfell ... Camera.zip
or the Exe here: http://members.rogers.com/jamiegoodfell ... eraExe.zip
After downloading, copy sydney.bmp, sydney.md2, and map-20kdm2.pk3 to your project's working directory, or the same directory as the Exe. You'll also have to get irrlicht.dll yourself, version 0.4.2 (Don't want to waste too much of my web space). There's no error checking or anything, so the executable will crash if these aren't in the correct location.
Controls are:
Mouse movement: rotate camera
+/- keys: Zoom in/out
Arrow Keys: Move Sydney
Caveat: You have to hold down the arrow key for a second or two before Sydney really starts to move. I just hacked together some movement code after finishing the camera code to get everything working, so movement isn't the greatest.
You can download the project here: http://members.rogers.com/jamiegoodfell ... Camera.zip
or the Exe here: http://members.rogers.com/jamiegoodfell ... eraExe.zip
After downloading, copy sydney.bmp, sydney.md2, and map-20kdm2.pk3 to your project's working directory, or the same directory as the Exe. You'll also have to get irrlicht.dll yourself, version 0.4.2 (Don't want to waste too much of my web space). There's no error checking or anything, so the executable will crash if these aren't in the correct location.
Controls are:
Mouse movement: rotate camera
+/- keys: Zoom in/out
Arrow Keys: Move Sydney
Caveat: You have to hold down the arrow key for a second or two before Sydney really starts to move. I just hacked together some movement code after finishing the camera code to get everything working, so movement isn't the greatest.
very good!!!
i think you have only to work on small things... as you said : the movement of sydney is poop. then: if i move my mouse to the left side i want sydney to turn left. A big "bug" is, that if you look on the bottom, sydney wont move very much. anyway think you did it quite well.
i think if it becomes part of the engine it woud be better if it doesn't do evervthing for the user. maybe a function, that calculates the camera position out of 2 parameters (mousex,y). some people maybe don't want to use the engines mouse-input (low precition)
i think you have only to work on small things... as you said : the movement of sydney is poop. then: if i move my mouse to the left side i want sydney to turn left. A big "bug" is, that if you look on the bottom, sydney wont move very much. anyway think you did it quite well.
i think if it becomes part of the engine it woud be better if it doesn't do evervthing for the user. maybe a function, that calculates the camera position out of 2 parameters (mousex,y). some people maybe don't want to use the engines mouse-input (low precition)
hrm, didnt wanna run...
well i havent tried recompiling it yet, but the exe didnt wanna run for me. i copied all the files you mentioned into the directory i extracted it to. dunno...
i also have a 3rd person cam in FMORG, my project, but mine instead rotates with the arrow keys. one of the thing i can tell you is that one reason you might have to wait a sec for her to really move is because it is waiting on the key repeat. you can see if you look in my event receiver class in fmorg, that the keydown event simply switches the movement on, and the keyup switches it off. the movement iteself is done by a function i call during the render loop.
this may not be the best way to do it, it prolly slows down my render loop for it to jump out and do that during, but i still get a respectable FPS with it...
-Ted
i also have a 3rd person cam in FMORG, my project, but mine instead rotates with the arrow keys. one of the thing i can tell you is that one reason you might have to wait a sec for her to really move is because it is waiting on the key repeat. you can see if you look in my event receiver class in fmorg, that the keydown event simply switches the movement on, and the keyup switches it off. the movement iteself is done by a function i call during the render loop.
this may not be the best way to do it, it prolly slows down my render loop for it to jump out and do that during, but i still get a respectable FPS with it...
-Ted
My irrlicht-based projects have gone underground for now, but if you want, check out my webcomic instead! http://brokenboomerang.net
Hell_bird: I am soon going to make a second style of 3rd person camera that is more like a Tomb Raider style 3PC, so it will always stay behind the character. Hopefully I'll get it to flow nicely so if the character turns too quickly the camera will lag a bit. I think I know how I can fix the syndey not moving much if looking from the bottom issue. I'll look into the Sydney always facing forward thing as well.
Buhatkj: Are you using the irrlicht 0.4.2 VisualStudio dll? Also, you are correct about the keyboard inputs lagging. I wasn't too woried when doing the movement since the main thing I wanted to present was the camera movement itself.
qwe: This has been done by somebody else, if you search the forum you should be able to find details. But basically, just hide the cursor, and stick a crosshair image in its place (using a GUI element). Every frame, update the image's location based on the mouse's current location. Since my animator repositions the mouse immediatly after a scene draw, you shouldn't have to worry about the image jumping outside of the inner box (as the cursor does sometimes).
Buhatkj: Are you using the irrlicht 0.4.2 VisualStudio dll? Also, you are correct about the keyboard inputs lagging. I wasn't too woried when doing the movement since the main thing I wanted to present was the camera movement itself.
qwe: This has been done by somebody else, if you search the forum you should be able to find details. But basically, just hide the cursor, and stick a crosshair image in its place (using a GUI element). Every frame, update the image's location based on the mouse's current location. Since my animator repositions the mouse immediatly after a scene draw, you shouldn't have to worry about the image jumping outside of the inner box (as the cursor does sometimes).
Fixing sydney moving
If you want to fix the movement of sydney so that she responds right away dont do the movement and animation in the event receiver, put it all in function that is called from the game loop. In the event receiver just set variables such
this will get rid of the little delay between when the anim starts and the char runs. I do all this in classes of course with class private variables.
I also wrote a better collision detection for firing my weapons. In the techdemo the way firing is done assumes that a bullet hits the target as soon as you shoot. If you have a slower projectile you will hit the player even though they have moved out of the way when the bullet actually gets there.
Code: Select all
if(event.KeyInput.Key == irr::KEY_UP)
{
if(event.KeyInput.PressedDown)
sydney->setForward(true); // set forward sets a variable
else // bool move_forward
sydney->setForward(false);
}
then have a function that you can call from the game loop:
void animate()
{
if(move_forward)
forward(); // forward() sets anim to run and moves node
/// etc check for rest of conditions
}
I also wrote a better collision detection for firing my weapons. In the techdemo the way firing is done assumes that a bullet hits the target as soon as you shoot. If you have a slower projectile you will hit the player even though they have moved out of the way when the bullet actually gets there.
Alright, I've updated the zip files, the links are still at the top of this thread. I've fixed the bugs Hell_bird mentioned, fixed up Sydney's movement so it is smooth (I did this using another SceneNodeAnimator, it should be easily extensible, feel free to use it), and added some quick crosshair code as a demo for qwe. Let me know if you think of some other improvements it could use.
here are my thoughts on the subject.
There's bug where left/right on the mouse are inverted, i.e. when you move the mouse left, the character turns right, etc.
I don't think the mouse is reponsive enough, but that's just opinion.
When you hit the down arrow, the character should walk backwards, not turn around and walk into the camera.
There's bug where left/right on the mouse are inverted, i.e. when you move the mouse left, the character turns right, etc.
I don't think the mouse is reponsive enough, but that's just opinion.
When you hit the down arrow, the character should walk backwards, not turn around and walk into the camera.
looks good
Yeah that looks good now, I agree with the backwards thing and the mouse axis buts maybe thats the way you intended it, and it would be easy to change anyway.
I think that will help alot of people who were posting about getting thier 3rd person camera!
Byron
I think that will help alot of people who were posting about getting thier 3rd person camera!
Byron
Yes, the character movement and crosshair position are where I intended them to be. The character doesn't turn at all when you move the mouse, the camera rotates around the character.. so when you move the mouse left, it rotates leftward around the character.
To make the mouse more reponsive in your own projects, just set the mouse speed value in the animator constructor.
As I said, I made the camera and player movement to mimic Star Wars Galaxies. I will make another one (perhaps Wednesday when I'm stuck at school with nothing to do again) that mimics Tomb Raider style controls, which will have the character move backwards when pressing down, have the camera look where the player is looking, etc.
To make the mouse more reponsive in your own projects, just set the mouse speed value in the animator constructor.
As I said, I made the camera and player movement to mimic Star Wars Galaxies. I will make another one (perhaps Wednesday when I'm stuck at school with nothing to do again) that mimics Tomb Raider style controls, which will have the character move backwards when pressing down, have the camera look where the player is looking, etc.
Boogle - great work - i think one of the strengths of irrlicht will be these addable classes - it would be great if we can keep them relatively self contained, simple and updated - Niko, do you think there could be a place on the server to host them and a page to list them? - if not i might be able to do so on my ping.net server - and i would be willing to organize the object list
objects i have seen so far:
- Boogles camera code as above
- fmorgs player character object (and possible an npc as a subset of this)
- 2D library (is this going to remain separate Niko or will it be incorporated into the core of irrlicht?)
i imagine there are others i have yet to see in the forums
objects i have seen so far:
- Boogles camera code as above
- fmorgs player character object (and possible an npc as a subset of this)
- 2D library (is this going to remain separate Niko or will it be incorporated into the core of irrlicht?)
i imagine there are others i have yet to see in the forums