making camera go up stairs fps type camera

Started by
21 comments, last by Anddos 13 years, 6 months ago
I am finding it hard to figure out how to make the camera walk up stairs , how is done exactly , i have a feeling its done with picking but could be messy or getting the hieight y value of the steps vertex and setting the camera position to that...can anyone shed some light on this, as its got me baffelled... the stairs is a seperate mesh from the corridor btw..
:)
Advertisement
Depends on what routines you have available in your engine. You can certainly do picking - shoot a ray "down" from your camera position to get an elevation. If your application has a collision engine included, you can use a bounding sphere for the camera and let collisions between that sphere and the "terrain" determine the camera location.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

but lets says i place a pick ray like you suggest , if i am heading towards the stairs , its going to pick the triangle thats facing the camera and not the actual steps, plus what if the player is looking upwards and still wants to move up the steps , what happens then as the pick is going to pick the steps further up etc..

see the blue triangle is the picked triangle, if i was to get that the height of that it would make no sense :/
http://img19.imageshack.us/img19/8323/picksteps.jpg
:)
Its only going to pick whats in front if you shoot the ray from the camera forward in the look direct, you want to pick whats below the player then shoot the ray down.
Physics systems like bullet or nvidias physx have character controllers that auto step up a given height, making things like this a lot easier, thats what I would suggest using, unless you are trying to do it yourself that is.
Quote:Original post by NumberXaero
Its only going to pick whats in front if you shoot the ray from the camera forward in the look direct, you want to pick whats below the player then shoot the ray down.
Physics systems like bullet or nvidias physx have character controllers that auto step up a given height, making things like this a lot easier, thats what I would suggest using, unless you are trying to do it yourself that is.


if try placing a ray at the camera positon with a direction of 0,1,0 , then its going to pick the underside of the steps right?
:)
Just to try and clear up some confusion...

What was suggested is that you shoot a ray from your camera's position downward and find the ground.

This isn't done through picking (the process where you find whats under the mouse on the screen), this is done through what's called a ray cast.

Basically you test a ray for collisions against your world geometry.

It doesn't have anything to do with what is or is not on screen or under the mouse.

It has more to do with what is under the player's feet and how far it is to the ground from the player's current position.

Also if wondering, often times even though the stairs look like steps, the collision object for them in games is often a ramp. That makes the camera go smoothly up it and simplifies some other things (esp navigation mesh pathfinding type things).

If you go the route of actually having stairs in the collision geometry, you will probably want to smooth the camera movement to make it not look jerky as you go up and down steps. One way to do this is to interpolate to the camera's target position over time instead of teleporting it there each frame.

HTH!
if i do this i get nothing
D3DXVECTOR3 RayPos(gCamera->mPosW.x,gCamera->mPosW.y,gCamera->mPosW.z + 1.0f);
D3DXVECTOR3 RayDir(0.0f,1.0f,0.0f);


D3DXMatrixInverse(&i,NULL,&(bl2->BuildingWorld * gCamera->view()));
D3DXVec3TransformCoord(&TransPos,&RayPos,&i);
D3DXVec3TransformNormal(&TransLook,&RayDir,&i);
D3DXVec3Normalize(&TransLook,&TransLook);
D3DXIntersect(bl2->Mesh,&TransPos,&TransLook,&Hit,&FaceIndex,NULL,NULL,&Dist,NULL,NULL);
if(Hit)
{
//MessageBox(NULL,"Hit","",0);
sprintf(buffer,"%s %d %f","Hit",FaceIndex,Dist);
SetWindowText(FindWindow("D3DWndClassName",NULL),buffer);
//pm->RenderPickedTri(bl2->Mesh,bl2->BuildingWorld,FaceIndex);
}
:)
removed

******************************************************************************************
Youtube Channel

well isnt it better to pick the steps from underneath?
then the Dist float would tell me how much i need to add to camera.y etc
:)
It's because TransPos is the starting position and TransLook is how far out you test (as in it's next position to test too). I am referring to the layout you used in this function...
D3DXIntersect(bl2->Mesh,&TransPos,&TransLook,&Hit,&FaceIndex,NULL,NULL,&Dist,NULL,NULL);

Edited : its absolute, not relative positioning, oops

******************************************************************************************
Youtube Channel

This topic is closed to new replies.

Advertisement