Adding a weapon to FPS

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.
Th3one
Posts: 17
Joined: Fri Nov 25, 2005 11:43 am

Adding a weapon to FPS

Post by Th3one »

hi there guys,

Firstly I should start by stating I'm new to using the engine :D Loving it so far, run through the examples etc and understand most stuff. Unfortunately only being 16 means I cant quite match most of you guys in c++ experience (i probably havent been alive as long as u guys have been coding hehe) but i do have about 3years practice with it so I feel I know enough to use the engine quite well...

My ultimate aim is to create a very basic first person shooter. Then keep remaking it adding more each time until the game is of a great quality...

I learnt last night how to load in my map from doom3 :D I have to say it looked ace...absolutely perfect. I now want to add to this by adding a weapon to the view like in most FPS games.

How would I go about this? Should I model it in 3dsmax? And how would I go about rendering it so it is always visible in the bottom left of the screen? At the moment I just want the weapon to be displayed...It doesnt even have to be able to shoot.

Any help really would be appreciated guys :D thanks
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

weapon->setParent(camera);
weapon->setPosition(wherever);
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Th3one
Posts: 17
Joined: Fri Nov 25, 2005 11:43 am

Post by Th3one »

cheers :D How would I use that to load in my weapon made in 3dsmax though? Sorry if i'm being a n00b lol - just need to get used to using the engine
Guest

Post by Guest »

Make it in max and export it to .X or .My3d (or whichever format) if you want animation on the weapon then .X.

Load it in irrlicht using the relevent mesh loader and then just do what bitplane posted.

btw if you re 16 and have 3years experience with c++ (even if it is basic) then you are doing well, by the time you are in your mid 20s you should be a coding genius ;)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

erm you said you read the examples? :P

IAnimatedMeshSceneNode *weapon = smgr->addAnimatedMeshSceneNode( getMesh("gun.3ds"));
or something like that, I dunno. Try reading 'hello world' again. :D
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Th3one
Posts: 17
Joined: Fri Nov 25, 2005 11:43 am

Post by Th3one »

ah ha cheers guys :D Will try it as soon as i get home from college...hehe i read the examples yea...just wasnt to sure on how to use what i'd learnt to load an image that doesnt move. eg...the quake 3 map moves when you move the camera (obviously) wasn't quite sure how to add something that didnt move :P

Hehe cheers...Thought I'd learn early :D To be honest I'm only at a very basic level with it, but hopefully I'll improve leaps n bounds as I learn to write this game.

Also just as a side note...how good is the engine for use with Vb? Might use it in some college projects, spice up my vb lessons a bit hehe...so boring. I'm sat here being taught the very basics that i learnt years ago :o( I wanna do something that tests me a bit more :D
JPulham
Posts: 320
Joined: Sat Nov 19, 2005 12:06 pm

Post by JPulham »

hey, don't worry about experiance...they say those who start young become better coders...in general the best started from a young age. :P
I'm 15 and I've been into C++ for 5 years!!! :shock:
pushpork
Th3one
Posts: 17
Joined: Fri Nov 25, 2005 11:43 am

Post by Th3one »

hehe okies :D I have my weapon loaded into my game now. But I'm really struggling to work out how to get it to stay in the bottom right corner of my screen as i move the mouse and run around the map. I need to lkink it to the camera in some way like in every First person shooter but I'm not quite sure how?

Any help really would be appreciated... And thanks to all those above who helped :)
Th3one
Posts: 17
Joined: Fri Nov 25, 2005 11:43 am

Post by Th3one »

ok...I've managed to work it out :D Works quite well but there's still a few things I need to sort out. Firstly though in case anybody has had the same problem as me, or would like to see a simple way of graphically implementing a weapon into a fps game here's the code I'm using:

Code: Select all

scene::IAnimatedMesh* weapon = smgr->getMesh("../../Static Meshes/assaultrifle.3ds");
scene::IAnimatedMeshSceneNode* weapon1 = smgr->addAnimatedMeshSceneNode( weapon );

weapon1->setParent(camera);
weapon1->setPosition(core::vector3df(72,-80,110));
Now I have one problem remaining...When ever the gun goes near a wall in my map part of it sinks into the wall and disappears. Is there anyway of making sure that all of the gun is always visible on screen no matter what?
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Do you mean collision detection? There is a simple example in the BSP loader example.
Th3one
Posts: 17
Joined: Fri Nov 25, 2005 11:43 am

Post by Th3one »

yeah I know...the problem is as the weapon collides with a wall or part of the map (floor, stairs, wall etc) it sinks into it and disappapears. Nobody seems to have an answer to this problem...yet so many games using the engine are FPS games with guns...so how do their guns not disappear?
Guest

Post by Guest »

Turn of the ztesting for the weapon mesh - and draw it LAST always - then it is never drawn inside another object.. could also increase your collision radius to include your weapon.

:)
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Even in Planetside, an MMO FPS game from SOE ( Sony ) the weapons go into walls.

2 options to resolve it, that I can think of :

Just make walls thick enough, so weapons didn't stick out the other side and not worry about the gun going into walls.

Or, as was said in another thread, increase the radius of the collision around the camera so the weapon is included.
Image
Th3one
Posts: 17
Joined: Fri Nov 25, 2005 11:43 am

Post by Th3one »

ok ok...gunna have to make collision size big enough to include weapon. Is there a way of giving the weapon a collision sensor that stops the fps camera moving when the weapon collides with something?
Guest

Post by Guest »

Anonymous wrote:Turn of the ztesting for the weapon mesh - and draw it LAST always - then it is never drawn inside another object.
why not try this? it saves positional fur-bars and always works - there is never anything to be drawn on the screen side of the weapon only behind it - plus you get a speed boost by not z-testing it.

ah well
Post Reply