Weapons and Firing

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
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Weapons and Firing

Post by monkeycracks »

I need to know how to program weapons and shooting into my game. I am working on a Single Player First Person Shooter and I cannot figure out no matter where I look how to program weapons and shooting in. Please help. Thanks
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

a) How do I trap keyboard/mouse events? (keydown, mousedown, etc)
b) How do I calculate the trajectory of a bullet from the direction that the camera is facing?
c) How can I use Irrlicht's particle engine to make a ricochet effect when a bullet collides with the map?
Ismarc
Posts: 6
Joined: Sun Apr 02, 2006 8:40 pm

Post by Ismarc »

http://irrlicht.sourceforge.net/tutorials.html
http://irrlicht.sourceforge.net/tut007.html
http://irrlicht.sourceforge.net/tut008.html

Everything you are wanting to do is clearly and brilliantly outlined in the tutorials. I highly suggest walking through each tutorial, in the order posted. I also suggest against cutting and pasting the code in, as that doesn't help you. Hand type it in and understand what each piece is truly doing before you move onto the next portion. It goes a long ways when learning a new API.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I do hand type. I need to know though, because I cannot see where it shows that. Even if you only outlined the part where it shows you "how to attach a particle emitter to your camera and make particles move away from it in a straight line at a fast speed and collide with an object"

I see where I can get the collision details, but not the particle.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

As a matter of fact, it doesn't go into much detail on how to make objects not part of the map collidable either. I can't just read and magically know the exact code to use.
The collsion response animator can be attached also to all other scene nodes, not only to cameras. And it can be mixed with other scene node animators. In this way, collision detection and response in the Irrlicht
It does not say exactly how I could
Ismarc
Posts: 6
Joined: Sun Apr 02, 2006 8:40 pm

Post by Ismarc »

I'm sorry about that, I didn't get the third tutorial needed in there that showed more of the special effects.

http://irrlicht.sourceforge.net/tut011.html

Specifically, look at the portion labeled "add light 1 (nearly red)" and "add light 2 (grey)" of tutorial 11 and "create light" of tutorial 8. You then need to look specifically at the portion of the while loop of tutorial 7, from just after the smgr->drawAll() to driver->endScene().

The per pixel lighting and specialfx tutorials both have animated effects that can easily be adjusted to move in a straight line. The collision tutorial shows you how to find out what it would collide with, as well as how to implement collision for it. All you have to do is set the start location as the camera's position, then animate and move it the right amount each frame until it hits the target of the camera when it was fired.

To understand how the collision works, look closely at how the camera is animated in the tutorial. You can add that same animator to other nodes to make them collide with the map as well.
area51
Posts: 338
Joined: Thu Mar 18, 2004 10:20 pm
Location: UK
Contact:

Post by area51 »

You can look at the Irrlicht tech demo also for firing, it uses an animator and bilboard. Press space bar to shoot.

To get objects other than the map to collide, you need to create a MetaTriangleSelector, and then add the TriangleSelector of the objects you want to collide to that.

You can have a look at IrrWizard for both shooting and making objects with collision detection. ie you wont be able to go through the main enemy if he stands in your way.

Good luck :D
________
DEMENTIA ADVICE
Last edited by area51 on Thu Feb 24, 2011 11:59 pm, edited 1 time in total.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Thanks :D
Post Reply