Mysterio wrote:Well, I was planning on making a 3rd person shooter game but now I've changed my mind, I'm now trying to make a 1st person game that [irrelevant]. I want it to be like any other FPS game with the mouse and keyboard as the controllers. I want the player to be able to walk, run, climb, [irrelevant] all I need is for my character to do what I want it to when I press a key like say "W" to run forward. I hope this gave you the info u need rogerborg. Now can u please help me?
I'll try, really I will. However, there is no cookie cutter step-by-step solution, at least not one provided directly by Irrlicht. You have a huge amount of work ahead of you. Even a simple FPS is man years of work for an experienced developer.
First, you have to decide what sort of interaction your actors will have with the game world. If your game world is mostly static, then you can use Irrlicht's triangle selectors (ITriangleSelector).
That is covered in both example 07.Collision, and the Demo example. You create triangle selectors from your world geometry using ISceneManager::createOctTreeTriangleSelector() or ISceneManager::createTriangleSelector(). You can group them together by adding them to a meta triangle selector (ISceneManager::createMetaTriangleSelector() ), which you can then use as though it were a normal triangle selector.
Then you create a collision response animator (ISceneManager::createCollisionResponseAnimator()) from your triangle selector. Determining an appropriate size for the ellipse is entirely your responsibility; it should be based on your model sizes so that their physical presence matches their appearance.
You then add that collision response animator to whatever node(s) that you want to not fall through the world. The examples show adding it to a camera scene node. I strongly advise not doing this, as it gets you into the mindset of thinking that the camera is an actor's physical presence, which is only true for your first person avatar.
That stops your nodes falling through the world. Moving them around is another issue.
You can use the FPS camera for this, but that is the wrong solution. It's designed for putting together simple demos quickly, not for use in a real game. You should decide on a movement scheme that's common for all actors (your player and all NPCs). How you do that is up to you: Irrlicht (a
3d engine) neither proscribes nor provides any particular solution. You need to decide how fast an actor can turn, how fast they can move and in what directions (forwards? backwards? sideways?).
Changing the rotation of their Irrlicht nodes is a matter of calling setRotation(). To find what direction (i.e. a direction vector) that leaves them facing in the world, you have to use trigonometry. Really, you do. Search the forums for atan2().
Turning their direction vector into a speed (depending on whether they are walking or running) is up to you. In general, you'll normalize() it, then multiply it by a frame time, and a speed factor, then add it to their current position with something like actor->setPosition(actor->getPosition() + movementVector);
"Climbing" is a whole new set of problems. Since the collision response animator is unlikely to be flexible enough for that, you'll have to find some way of identifying climbable world geometry (using fake joints would be
one way) and decide whether an actor is close enough to the climbable surface/object to climb it, and in which direction they're going, then you can move their Y position up and down.
I'm really sorry, I know this isn't the answer you wanted. You wanted a "makeFPS()" function. In fact, I think I'm really wasting my time typing all this, but it's honestly the best answer that I can give. Game development is hard. I repeat my suggestion that you use IrrWizard to build a basic framework for you, or find some other game creation toolset, because writing a FPS from scratch using only a
3d engine is a very, very ambitious proposition.