Gun going through walls

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
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Gun going through walls

Post by RayOfAsh »

http://img.photobucket.com/albums/v317/ ... seggun.jpg

Heres the code for the gun:

Code: Select all

//Weapon
	
	irr::scene::IAnimatedMesh* wepMeshRifle; 
	irr::scene::IAnimatedMeshSceneNode* wepNodeRifle; 
	wepMeshRifle = smgr->getMesh("rifle.md2");  //The Rifle is loaded here.
	
	wepNodeRifle = smgr->addAnimatedMeshSceneNode(wepMeshRifle, camera, -1);  //The camera is now the Rifles parent.
	wepNodeRifle->setScale(core::vector3df(100,100,100));
   wepNodeRifle->setPosition(core::vector3df(150,-400,450));
   wepNodeRifle->setRotation(core::vector3df(0,0,0));
How do I fix this? Also when I put in the code to give it its texture, it crash's:

wepNodeRifle->setMaterialTexture(0, driver->getTexture("rifle.bmp"));

It says it loads it, then it crash's without giving an error in the console.
Image
Dogs
Posts: 195
Joined: Wed Sep 15, 2004 1:04 am
Location: michigan

Post by Dogs »

I see this problem in many demos...
You nead to add collision to your gun as well so that it bumps into the wall and dosnt go into the wall...
At this point im sure you only have the collision added to your cam so is only your cams bounding points that are actually colliding with the walls not the gun.. :)
I havent messed with the settings but ive read someplace here in the forum that you can addjust these bounding settings for your cam and maybe just simply incres them larger to acomidate the space for the gun...
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

In fact this problem is solved in easyer way usualy: You have to set your gun to be rendered over all other objects on screen ...that way even if your gun will go through wall to player it would not look so, he will allways see it.

If you add colision detection it will make things more complicated and may even slow down game a little bit.

Only problem is that I don't know if there is function for doing so in Irrlicht, personaly I newer encoutered one ..but was newer looking for one till now.
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

Wouldn't node->render() after smgr->drawAll() work fine?
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Post by RayOfAsh »

bal wrote:Wouldn't node->render() after smgr->drawAll() work fine?
Apparently not, although I really dont know how to use this function.

I put:

wepNodeRifle->render() after smgr->drawAll();

after just seems to cause bugs, and if I put it like this:

wepNodeRifle->render(); smgr->drawAll();

It crash's :lol: .

I checked the API and found that drawAll() and render() are functions, and OnPostRender(). So I its somthing on my part, what am I doing wrong?

Also, instead of spamming and creating a new thread, ill just ask this here. I have some funky lighting going on in my map, everything is dark. Is there a way to make it, not dark?

Check it: http://img.photobucket.com/albums/v317/ ... /SEGA2.bmp

I dont want to have to go and put lights everywhere in the quake 3 map.
Image
BUMP

Post by BUMP »

bumpy!
nicesun
Posts: 9
Joined: Mon Dec 27, 2004 1:32 pm

Post by nicesun »

Hi ,

I've got the same problem...

Do we have to add a collision detection to the gun ?

This is no good, because I would like my character to get very close to a wall
without having his gun disappear !!

help !

EDIT

I found a practical solution that might not please everybody
but it works for me :

Try scaling down your gun, and ajust coords to make still appear before you.
The goal is to include your model into the collision detector perimeter...

This works like a charm for me..
I guess that the model isn't truly scaled with the world, but who cares ?



/EDIT
Post Reply