FPS: collision with enemy,shooting,etc.

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.
thoma91
Posts: 28
Joined: Tue Aug 09, 2011 10:00 am

FPS: collision with enemy,shooting,etc.

Post by thoma91 »

Hi! I'm relatively new here.
Till now I've just read the forums, but now I have to ask you some questions.
I hope some will help me, because I'm short of time, and please, if you just can say: "This isn't enough time" or "Try to learn more" or "Figure it out yourself", don't even bother with it.

I have to do a simple FPS project.

I've done these things so far:
-own map (made with Gtkradiant)
-collision detection (only with walls, not with enemy)
-loaded a 3d enemy

What I need:
-collision with enemy
-adding weapon
-shooting with weapon
-simple enemy AI,move towards me,and attack me
-shooting down enemy

If you can add me code examples, I would highly appreciate that, but that would be a great help too, if you just tell me how to do this.

Could you please help me in these? It's really important to me, and this forum is the last hope I think.
If you can't help in all, but some, that would be great too.
Contact me here, or in PM.

Thanks in advance,
regards:
thoma91
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: FPS: collision with enemy,shooting,etc.

Post by Radikalizm »

Even if you don't want to hear this, the things you listed are not things you can implement in a short time; even worse, if you still have to figure out basic concepts, or if you still have to learn how a certain library works (eg. physics, for your collision handling) you have to keep in mind that you'll almost be doubling the time spent implementing everything

Games are not something you can rush and implement in a week time, especially if you're still learning, whether you like this fact or not

Could you tell us what your exact timeframe is? If it's not too bad you could still try to implement some of the listed features, but since what you listed is pretty much the core of your game (Irrlicht easily handles all the features you already have) and since it will require a lot of work to get right, you'll probably have to live with the fact that you won't get everything implemented
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: FPS: collision with enemy,shooting,etc.

Post by sudi »

Well Radikalizm is not telling the whole truth here. Because it depends how you want this done. If that is all the features you want and you don't care about modular design or anything else implementing this is maybe a matter of a hour or two.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: FPS: collision with enemy,shooting,etc.

Post by Radikalizm »

Sudi wrote:Well Radikalizm is not telling the whole truth here. Because it depends how you want this done. If that is all the features you want and you don't care about modular design or anything else implementing this is maybe a matter of a hour or two.
If you know exactly what these features require, and if you know exactly what you're doing you could implement this in a small amount of time, I agree with you there, but I'm talking about a clean, well-written and debugged implementation here (as it should be) together with the amount of time you'd need to grasp the concepts behind all of the features
AI and physics systems for example aren't things you can immediately master, so you should definitely allocate some time for that next to the actual implementation
thoma91
Posts: 28
Joined: Tue Aug 09, 2011 10:00 am

Re: FPS: collision with enemy,shooting,etc.

Post by thoma91 »

Hi guys! Thanks for the answers! I have to do this until the 1st of September.
Could you help me to succeed in this?
I know I can't rush, but I can't learn everything in 3 weeks, that's the reason I asked for your help.

First step: how could I collide with the enemy?
My first thought was to create a second selector (by the way I'm using the Collision example as starting point), which is attached to the enemy node (instead of the Q3 level), but I think that's not the proper solution. (I can't try it out, because I'm not at home at the moment.)

Thanks in advance for your help.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: FPS: collision with enemy,shooting,etc.

Post by serengeor »

why not just get a physics engine, wrapper(not necessary but might be easier) for it and using its examples do what you need?
Working on game: Marrbles (Currently stopped).
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: FPS: collision with enemy,shooting,etc.

Post by Radikalizm »

serengeor wrote:why not just get a physics engine, wrapper(not necessary but might be easier) for it and using its examples do what you need?
Exactly, irrlicht's collision systems are meant for small demo's and prototypes, not for actual games
If you want optimal collision detection you should go for a full physics engine; this will get better performance than irrlicht's built in collision detection, and you'll have a complete package for everything physics-related

To give a suggestion, I'd recommend trying out Bullet; its API is very easy to understand, and you can have a physics demo set up in no time
thoma91
Posts: 28
Joined: Tue Aug 09, 2011 10:00 am

Re: FPS: collision with enemy,shooting,etc.

Post by thoma91 »

Thanks, I downloaded irrBullet, and I'd like to try it out, but its project files are in cbp format (codeblocks project), but I'd rather use my Dev-Cpp.. Is there a way to convert cbp to dev project? I searched google, but found nothing.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: FPS: collision with enemy,shooting,etc.

Post by sudi »

thoma91 wrote:Thanks, I downloaded irrBullet, and I'd like to try it out, but its project files are in cbp format (codeblocks project), but I'd rather use my Dev-Cpp.. Is there a way to convert cbp to dev project? I searched google, but found nothing.
Don't use Dev-Cpp! Its old outdated and all new IDEs have better features. Code::Blocks for example is a really good free IDE you should try it!
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

Re: FPS: collision with enemy,shooting,etc.

Post by TheMrCerebro »

For you know something...

-collision with enemy

Player

Code: Select all

 
PLAYER::PLAYER(core::vector3df pos)
{
       mesh = pScene->addMeshSceneNode( pScene->getMesh(" your file name ") );
       ...
       ...
 
        ITriangleSelector* selector;
        selector = pScene->createTriangleSelector( mesh->getMesh(), mesh );
        mesh->setTriangleSelector( selector );
}
 
void PLAYER::addCollision(ISceneNode* coll)
{
        ISceneNodeAnimatorCollisionResponse* anim;
        anim = pScene->createCollisionResponseAnimator(
                mesh->getTriangleSelector(),
                coll, // enemy
                vector3df(5.f,5.f,5.f), // radius
                vector3df(0,0,0),
                vector3df(0,0,0));
 
        coll->addAnimator(anim);
}
 
Enemy:

Code: Select all

 
bool ENEMY::getCollision()
{
        core::list<ISceneNodeAnimator*>::ConstIterator begin = mesh->getAnimators().begin();
        core::list<ISceneNodeAnimator*>::ConstIterator end   = mesh->getAnimators().end();
 
        for(; begin != end; ++begin)
        {
                ISceneNodeAnimator* anm = *begin;
 
                if(anm->getType() == ESNAT_COLLISION_RESPONSE)
                {
                        if( ((ISceneNodeAnimatorCollisionResponse*)anm)->collisionOccurred())
                                return true;
                }
        }
 
        return false;
}
 
-adding weapon

Code: Select all

 
WEAPON::WEAPON()
{
        mesh = pScene->addMeshSceneNode( pScene->getMesh( " your weapon " ), camera );
        
        //If necessary.
        mesh->setRotation( core::vector3df( 0, rot , 0) );
}
With this and a little knowledge in C++ you will do the rest :twisted:
What your trying to do is easy, but is not good idea waiting for a answer. Irrlicht brings good examples.

PD: If you need to do something fast and without programming, use the Unity (free edition).
Irrlicht is more for those who know something about programming.
Follow me on twitter: @themrcerebro
thoma91
Posts: 28
Joined: Tue Aug 09, 2011 10:00 am

Re: FPS: collision with enemy,shooting,etc.

Post by thoma91 »

Thanks! Now I'm done with the enemy collision, and I've got a weapon in hand.
Now I'm trying with shooting, looking at the code of the Demo example, but I can't figure it out, how to put the shooting code into the Collision example, because the program structure is totally different.
Any ideas?
thoma91
Posts: 28
Joined: Tue Aug 09, 2011 10:00 am

Re: FPS: collision with enemy,shooting,etc.

Post by thoma91 »

Ok, I'm stuck again.
I can shoot now, but the fireball doesn't collide with the wall, it just flies through..
I'm using the shoot & the createParticleImpacts functions from the Demo example, but it doesn't work correctly for me.
I know it's very small amount of information, but I think I don't need to copy the code here because the functions are the same as in the demo, and the program structure is very simple (based on Collision example,one main.cpp file only):
includes,variables,the 2 functions,eventreceiver for handling left mouse clicks;
main: simple things like map loading,camera,collision handling,etc.
Anyone got an idea, what did I miss out?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: FPS: collision with enemy,shooting,etc.

Post by serengeor »

"Copy paste and pray for it to work" is not the way to go if you want a good working project. Why don't you just use something like fps creator or even Unity if you need it to be done fast? Games don't just get programmed in a few days by beginner programmers you know :roll:
Working on game: Marrbles (Currently stopped).
thoma91
Posts: 28
Joined: Tue Aug 09, 2011 10:00 am

Re: FPS: collision with enemy,shooting,etc.

Post by thoma91 »

I know it's not the right way to copy-paste everything from examples, but I don't have time to fully understand and learn Irrlicht, I wrote it in the first comment..
I have to use an Engine like this, not just an "editor" like FPSCreator, so that's why I'm here.
I'm not doing this for fun, it's a task.
I'm ashamed to ask for so much help, and I know I'm a beginner, but the work has to be done.
So I'd appreciate, if someone professional (maybe you,serengeor), who knows how to create a simple game like this could dedicate some time to me.
It would be a great help, and I could learn from it too.
Thanks anyone who understands.
Greetings Image
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: FPS: collision with enemy,shooting,etc.

Post by serengeor »

thoma91 wrote:I know it's not the right way to copy-paste everything from examples, but I don't have time to fully understand and learn Irrlicht, I wrote it in the first comment..
I have to use an Engine like this, not just an "editor" like FPSCreator, so that's why I'm here.
I'm not doing this for fun, it's a task.
Sorry I'm a bit forgetful. I read that when I wrote my first post in this thread and forgot it right now.
Unity on the other hand is not just an editor, you can program things in it and get quite nice results in short time, but you would need to know how to program in one of the supported .NET languages.
thoma91 wrote: So I'd appreciate, if someone professional (maybe you,serengeor), who knows how to create a simple game like this could dedicate some time to me.
I'm not a professional programmer (though I would like to be one in future) and I can't help you that much. I have a project of my own which is moving forward very slowly ,but at least it's getting somewhere and that might be a good sign I guess.



A simple suggestion would be to write a wrapper for physics engine. Just take a look at already written ones and make a mini version of it that would have the features you need I.E: trimesh collision, bounding box collision for enemies (maybe something else?) and ray casting for bullets I guess. It shouldn't take long to write a wrapper that would have these features and you would also gain some valuable experience while doing so.

BTW, Why did you take a task that you don't know how to do? :roll:
Working on game: Marrbles (Currently stopped).
Post Reply