Best way to set up an FPS-Cam?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Robin

Best way to set up an FPS-Cam?

Post by Robin »

Hello I'm (still)trying to create a 2 player split-screen FPS game, thanks to all you people who have given me tips etc on this forum, I have come this far(2 separate controlable FPS cams with basic collision-det.). As I have no experience at all in FPS-game programming, I would like to ask if someone could tell me how I should deal with some issues.
1. Should I create a model with a cam(controlled by keys & mouse) as its parent. Or should I create a cam with a model(controlled by keys & mouse) as its parent. Its like the chicken and the egg for me, because the collision-det. should respond to the model, but controls to the cam(I think).

2. is it wise to let 'createCollisionResponseAnimator' do all the collision detection. or should I create my own routines for collision detection(and thus not use createCollisionResponseAnimator, but getSceneCollisionManager() ), or should I use some external engine like tokamak.
I'm asking this because when I use a (slightly modified) version of the FPS-cam from irrlicht, the collisiondetection from the animator is not very reliable(fall trough wall into void, or get stuck) when you crouch/jump/climb(own code)

3. is it possible to code some protection for clipping/getting stuck

Any link or help would be welcome
Greets, Robin
Phunk
Posts: 78
Joined: Sun Dec 14, 2003 8:18 pm
Location: The Netherlands

Post by Phunk »

hello, I'm now a registered user, but hasn't anyone got an awnser for my problem(above)? or did I post it under the wrong topic or something?(or should I just be more patient?)
Greets, Robin
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

You don't need to attach a model to your camera to get collisions to work with it. You can just attach a Collision animator like in the Collision Tutorial. It will create an elipse for the collision checks.

As for FPS physics, you don't really need Tokamak for it unless you want move physics than just a simple "Is A touching B?" and gravity.

I'm not too sure about what you are testing for on the getting stuck part. I believe that "If you can get yourself stuck, you should be able to get yourself unstuck." But after playing Deus Ex: Invisible war for a few hours, they present a few possiblilites for you to get completely jammed into a spot with no hope for unsticking. This might be something that you would have to check on a game logic level. Like, if the player is pressing all the movement keys and hasn't been able to move at all, bump them a little to get them out.

Most FPS games rely on the level designers not to make any points where players can get stuck, though.
Crud, how do I do this again?
Phunk
Posts: 78
Joined: Sun Dec 14, 2003 8:18 pm
Location: The Netherlands

Post by Phunk »

Tnx for reply, but the purpose for attatching a model to a cam is for the other player in the split screen to see you as you walk around. But If I just made the model follow the cam it will move in a very unnatural way(looking from the second players point of view). And for the getting stuck part: when I duck and crouch under an object(like I get under one of the bridges in the map of the loadQ3map tutor) and I release the crouch button, the elips of the cam cannot fit under it annymore, and it just goes trough the bridge, but then I cannot walk away anymore, because the col.det. still tests the edge of the bridge. Alse when I junp, I jump trough the map in some very rare cases(I think it is when I land right on the edge of 2 verticies with an angle of 90 degrees or so) I would alse like to remove the shaking of the cam when you walk against certain walls(with a small, like 10 cm, edge in front of it) in this level. I thougt that I could create a more smooth camera movement if it just loosely folowed the model.
I think that maybe I should do my own col.det then(trough the col.manager) but I thougt that maybe tokamak could do a more secure and better job than me. But I will folow your advice on the little bump when no keys work!
Thanks
angel80
Posts: 22
Joined: Mon Feb 07, 2005 1:37 pm
Location: Paris (France)

About the separate controled splitting screen

Post by angel80 »

Hello Phunk,
I would like to know how you can control the second FPS camera
Thank for your help
.: Franck :.
eXodus
Posts: 320
Joined: Tue Jan 04, 2005 10:07 am
Location: Canada
Contact:

Post by eXodus »

@saigumi

This is a functionality implemented in Postal²
When stuck, you were warped off a meter and a message told you to get away from that spot...literally :)
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post by SARIN »

for an FPS, i wouldnt advise setting the model to be the child (or parent) of the camera. obviously this would be because if the camera is pointing down, the character would be hovering or laying off the ground. wat u could do if u want to us the child and parent commands is to set the camera as a child of the bone of an upper torso or head, so that as the camera moves, the player will move to.

what i am doing with my fps is i use the irrlich fps cam, then i set the position of the player model at the camera, and set the players yrotation to the cameras. also, for collision, i am using my own system (although the jumping is screwed), it goes like this. (pretty slow and crappy code, but my point is put across)

mainloop here

Code: Select all

while(device->run()) {

     driver->beginScene(true,true,SColor(0,0,0,0));
     smgr->drawAll();
     driver->draw2DImage(cursor,position2d<s32>(304,224),
				rect<s32>(0,0,32,32),0,
				SColor(100,255,255,255),true);
     genv->drawAll();
     driver->endScene();
     camrot=cam->getRotation();
     vector3df vector = cam->getPosition();
     vector=SideCollision(vector);
     vector=vector3df(vector.X,vector.Y+jump+3.5,vector.Z);
     vector3df groundlvl=LevelCollision(vector);
     if(lvlcollision==true) {vector.Y=groundlvl.Y+6.5;jump=0;}
     else if(lvlcollision==false) jump=jump-.01;
     cam->setPosition(vector3df(vector.X,vector.Y,vector.Z));
     player->node->setRotation(vector3df(0,camrot.Y,0));
     player->node->setPosition(vector3df(vector.X,vector.Y-6.5,vector.Z));
also, i have these two collision functions.

Code: Select all

vector3df game::LevelCollision(vector3df pos) {
    if(jumping==true && jump>0) {return pos;}
    else {
    vector3df point=vector3df(0,0,0);
    line3d<f32> line;
    triangle3d<f32> tri;
    line.start=pos;
    line.end=vector3df(pos.X,pos.Y-7,pos.Z);
    if(sncl->getCollisionPoint(line,tris,point,tri)) {lvlcollision=true;jumping=false;}
    else {lvlcollision=false;}
    return point;}
}

vector3df game::SideCollision(vector3df pos) {
    vector3df point;
    line3d<f32> line;
    triangle3d<f32> tri;
    pos=vector3df(pos.X,pos.Y-3.5,pos.Z);
    for(int i=0;i<5;++i) {
    line.start=pos;
    if(i==0) {line.end=vector3df(pos.X+3,pos.Y,pos.Z);}
    else if(i==1) {line.end=vector3df(pos.X-3,pos.Y,pos.Z);}
    else if(i==2) {line.end=vector3df(pos.X,pos.Y,pos.Z+3);}
    else if(i==3) {line.end=vector3df(pos.X,pos.Y,pos.Z-3);}
    else if(i==4) {line.end=vector3df(pos.X,pos.Y+5,pos.Z);}
    if(sncl->getCollisionPoint(line,tris,point,tri)) {
    if(i==0) {pos.X=point.X-3;}
    else if(i==1) {pos.X=point.X+3;}
    else if(i==2) {pos.Z=point.Z-3;}
    else if(i==3) {pos.Z=point.Z+3;}
    else if(i==4) {pos.Y=point.Y-5;}
    }
    else {lvlcollision=false;}}
    return pos;
}
Post Reply