Muzzle flash positioning problem

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
Dibalo
Posts: 30
Joined: Sat Aug 12, 2006 2:31 pm
Location: Finland
Contact:

Muzzle flash positioning problem

Post by Dibalo »

Ok.. This is a n00b question and may be asked many times. Still I have spent with search many hours with no succeed. So I finally gave up and made this topic..

Let´s see... The problem is this: I´m using ILightSceneNode to create a muzzle flash. I have attach one billboardSceneNode to light´s child. So, the billboard (flame-image) and the light should be in the same position. Then I create an own camera (not FPSCameraNode) with my own movement and rotating methods. Then I attach the ILightSceneNode (which I made before) to camera´s child node and moved it a little bit forward. Now the light should move exactly same as the camera, right?

Now I turn the muzzle flash "on". When I move the camera, the muzzle flash image is always in the correct position. Everything is ok.

PROBLEM:
Now I´m going to make the shooting. If mouse button is down and an interval (reload-variable) is 0, the gun will shoot. I check this once per frame: if shooting is happened, I´ll make the muzzle flash visible. If not, I´ll make it invisible. THE PROBLEM IS THAT I have noticed that now the muzzle flash is not in right position. I is rendered with ping (meaning that if I turn or move my camera when I´m shooting, the muzzle flash appears in the location where my gun was on the previous frame)...

Here is my frame constuction:

Code: Select all

// start scene

// move the camera

// set the visibly of muzzle flash

smgr->drawAll();

// end scene
I have tried everything but it doesn´t work properly. Could you tell me, what I have done wrong? Or is there another, better, way to make muzzle flash? Thank you.

I apologize my bad English. :oops:
Dattebayo!!
Gatekeeper
Posts: 31
Joined: Fri Apr 21, 2006 12:00 am
Location: Australia

Post by Gatekeeper »

Try using updateAbsolutePosition() on your scene nodes before you set them visible. I can't guarantee this will help, but I had problems sort of similar to that and it fixed the problem straight away.
Dibalo
Posts: 30
Joined: Sat Aug 12, 2006 2:31 pm
Location: Finland
Contact:

Post by Dibalo »

Gatekeeper wrote:Try using updateAbsolutePosition() on your scene nodes before you set them visible. I can't guarantee this will help, but I had problems sort of similar to that and it fixed the problem straight away.
Thanks mate! :)

I´ll try this. I already solved this making light´s radius to 0 and resizing the muzzle flash image to 0,0. If shooting is happened, I´ll set radius and image´s size to correct values. But I think it´s a little bit too unstable and this way is better! Let´s see what happens.. :D
Dattebayo!!
Post Reply