How to bind a weapon before camera

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
thatax
Posts: 25
Joined: Thu Jul 31, 2008 7:33 am

How to bind a weapon before camera

Post by thatax »

just like counter-strike and half life,bind a weapon in front of the screen.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Search the forum if you've got a question because most of your questions will have been answered before.

Basically just use this:

gun_node->setParent(camera_node);
gun_node->setPosition(vec);

where vec is a position RELATIVE to the camera's position which will align it nicely to be on screen, this is just something you have to find with trial and error based on the gun model you're using.
Image Image Image
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

But wasn't it that unless you use the default FPS camera, the gun wont rotate along with the camera and you have to do it manually?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Not that i know of... but possibly, i've not used anything other than the FPS camera for this sort of thing.
Image Image Image
Jallenbah
Posts: 12
Joined: Thu Aug 14, 2008 12:10 pm
Location: Vector3df(20.6, 4, 19.2);

Post by Jallenbah »

It's not really a difficult challenge to work out how to get it to stay there. If you have the cameras current direction, you can point the gun in that direction at all times. Then, using the cameras current position and rotation, you can work out exactly where the gun needs to go. It's the kind of thing you just need to sit down and work out.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Eigen wrote:But wasn't it that unless you use the default FPS camera, the gun wont rotate along with the camera and you have to do it manually?
Yes, since scene node rotations and camera targets are independent. However, it's probably a safe assumption that this poster is using an FPS camera.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply