Weapon Positioning and AI

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
Haze

Weapon Positioning and AI

Post by Haze »

I have a numbers of problems hoping that someone will guide me as to what is to be done. Thanks in advance!!
1) How to placed a weapon on the enemy and as well as from the first person view?

2) Is the health of the player a .MD2 file? How can I keep a record of my character life?

3) Collision? When I run the Irrlicht engine in C++, I can shoot "red orb" by pressing the space bar. The "red ord" can collide perfectly onto walls resulting in some effect, but how I can detect the collision on the characters?

4) AI. What should I do to make the enemy chase after my character and and shoot him if they see him?

I am currently doing a project and need to get this done for submittion asap. I will apprepricate if anyone could help. =)

With a million thanks,
Haze
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

Hi

1) I don't really understand. Maybe try this: ISceneCollisionManager::getRayFromScreenCoordinates, and instead of the standard camera, create a new one and position it to the place of the enemy player.

2) The .md2 and other model formats cannot store these informations. You should track it yourself. E.g.:

Code: Select all

class Player {
   //...
   int health;
   scene::IAnimatedMeshSceneNode* video_scene_node;
   //...
};
3) I don't use Irrlicht collision system. If you want some advanced physics in your game, you might want to use a physical simulation engine too (ODE, Newton, Tokamak...). I use ODE and I prefer to use it's collision detection system instead of Irrlicht's one.

4) It is bit more complex topic than discussing all here :) You can find some great articles about game AI at GameDev.net

Toma
Last edited by WToma on Sun Oct 09, 2005 7:40 am, edited 1 time in total.
"This is not a bug, this is a feature!"
Guest

Post by Guest »

Thanks for your reply. My first question is that: how do I equipped a weapon to my characters? This is my code :

mesh1 = sm->getMesh("../../media/sorcerer.md2");
if (mesh)
{
model1 = sm->addAnimatedMeshSceneNode(mesh1); //sorcerer
if (model1)
{model1->setMaterialTexture(0, driver->getTexture ("../../media/sorcerer.pcx"));
model1->setPosition(core::vector3df(100,40,-80));
model1->setScale(core::vector3df(2,2,2));
model1->setMD2Animation(scene::EMAT_ATTACK);
model1->setMaterialFlag(video::EMF_LIGHTING, false);
// model1->setMaterialType(video::EMT_SPHERE_MAP);
model1->addShadowVolumeSceneNode();
}

From the code, I have imported sorcerer.md2 into the program and load the texture - sorcerer.pcx to it.
1) I am wondering how can I import the weapon so that it can be placed on the sorcerer hand?

2) Like counterstrike, I would like to see the weapon that I am carrying on my screen. May I know how am I able to do that?

Thanks.
Andreas
Posts: 166
Joined: Sun Oct 31, 2004 7:15 am
Location: Münster / Germany
Contact:

Post by Andreas »

1) Make the weapon a child of the sourcerer and call weaponNode->setPosition()??

2)Maybe you should place the camera in the sorcerer sceneNode, and you will see only the weapon i guess.

... and you should really start searching the forums, this has been asked a thousand times before... :?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

There's two other threads in this forum covering FPS weapony, so check them out, they may help you.

Try setting the weapon as a child to the character, that should work for the enemies i think, you may need to offset the position to actually line up the weapon though, but when i've done it it's put the weapons in the right place, but in animations they're a few frames out of sync....

If you look at the code from the tech demo tutorial (the one where you can fire the red orb) then you can see how they've done the collision detection with the walls, but what you need i think is a metaselector instead of a triangleselector, and then if you can get a triangleselector from the character then you can add that to the meteselector as well as the triangleselector for the map and that may work... I'm atleast hoping that will work as i'll be wanting to do something like that for my project!
Image Image Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I can confirm that the MetaTriangleSelector method works, as i've just managed to do it in my project, if you have trouble let me know and i can show some code, although it will be in java as i'm using a java binding for Irrlicht, but that just means you have to convert into C++ which is straight forward
Image Image Image
Haze

Post by Haze »

Thanks for the reply. JP, can u send me the code regarding the collision? I am a newbie in game programming and thats why I had so many problem. Also, I dont really understand how I can set the weapon to be the child of the characters?

Pls email me at: s8340567h@ntu.edu.sg

Thanks a lot!

Haze
area51
Posts: 338
Joined: Thu Mar 18, 2004 10:20 pm
Location: UK
Contact:

Post by area51 »

...for completeness
Weapon code for player camera:

Code: Select all

mesh1 = sm->getMesh("../../media/sorcerer.md2"); 
if (mesh1) 
{ 
	model1 = sm->addAnimatedMeshSceneNode( mesh1 , sm->getActiveCamera(), -1);  //sorcerer 
	if (model1) 
	{
		model1->setMaterialTexture(0, driver->getTexture ("../../media/sorcerer.pcx")); 
		model1->setPosition(core::vector3df(100,40,-80)); 
		model1->setScale(core::vector3df(2,2,2)); 
		model1->setMD2Animation(scene::EMAT_ATTACK); 
		model1->setMaterialFlag(video::EMF_LIGHTING, false); 
		// model1->setMaterialType(video::EMT_SPHERE_MAP); 
		model1->addShadowVolumeSceneNode(); 
	}
} 
This thread may help with adding a weapon to your characters:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7514
________
NEVADA DISPENSARIES
Post Reply