Controling a character

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.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Mysterio wrote:If anyone knows how to do it can you please give me a step by step procedure?
Your problem is undefined. I have no idea what sort of control you want. Keyboard? Mouse? First person? 3rd person? How much interactivity with the world? Jumping?

First, you need to decide exactly what it is that you want to do, then you can start to solve your problem. The examples that come with the SDK will indeed give you some ideas, but every problem - and therefore every solution - is unique.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Mysterio
Posts: 15
Joined: Sat Jan 19, 2008 1:41 am

Post by Mysterio »

rogerborg wrote:
Mysterio wrote:If anyone knows how to do it can you please give me a step by step procedure?
Your problem is undefined. I have no idea what sort of control you want. Keyboard? Mouse? First person? 3rd person? How much interactivity with the world? Jumping?

First, you need to decide exactly what it is that you want to do, then you can start to solve your problem. The examples that come with the SDK will indeed give you some ideas, but every problem - and therefore every solution - is unique.
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 involves swords and bows. 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, sword fight, shoot arrwos, use, open doors and yes the animation part is covered, 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? :(
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You might want to look into modding an existing game as first step. Most modern shooters offer tools for that, like an editor and a simpler scripting language. You won't have as much freedom as you have when writing a game from scratch, but it will be a lot easier to get into this and you also will learn a lot of basics which you will need when doing a more complex game.

Another way to get started is by learning to do simpler games first. Like trying to create a pacman or tetris - which is already a lot harder than most people expect.

Or if you want to learn more about Irrlicht start by working with the examples. Read them, compile them yourself and start modifying them. But you will need to learn c++ for that unless you find a programmer who will work with you.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

you should read your novella again rogerborg ;)

It's easy to cheat at all this, you could just make a new FPS style animator which is also an event receiver. Steal the code from the FPS camera and the collision response animator, use the functions in the collision manager to work out whether your feet are on the floor or you're still attached to a wall etc.

If you're making a really simple FPS with basic player AI then this will be one of the hardest parts, but also the most rewarding. so don't be put off!
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Funnily enough, I've never found that writing the requirements or design in fewer words leads to any reduction in implementation or testing. :P

Calling it a "FPS style animator" doesn't reduce the amount of work involved. And if it's based on the FPS camera and an event receiver, how does that work for NPCs?

Following your advice gets you a player presence that can run around a game world. Wheee! Now let's do NPCs.... uh oh. Time for a re-design, or duplication of work.

YAGNI is a fine idiom when you're a slave to other people's mad whims, but not when your requirements and design are entirely under your own control.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Mysterio
Posts: 15
Joined: Sat Jan 19, 2008 1:41 am

Post by Mysterio »

CuteAlien wrote:You might want to look into modding an existing game as first step. Most modern shooters offer tools for that, like an editor and a simpler scripting language. You won't have as much freedom as you have when writing a game from scratch, but it will be a lot easier to get into this and you also will learn a lot of basics which you will need when doing a more complex game.

Another way to get started is by learning to do simpler games first. Like trying to create a pacman or tetris - which is already a lot harder than most people expect.

Or if you want to learn more about Irrlicht start by working with the examples. Read them, compile them yourself and start modifying them. But you will need to learn c++ for that unless you find a programmer who will work with you.
I've already made four or five simple 2d games and one's similar to Pac-Man so I've had some experience in game development.
Post Reply