Problem about parent-child positioning

Hi guys!

I’m making muzzle flashes in my FPS game,i already have a weapon node so i decided to attach the muzzle flash node to the weapon.

Particles are ok,but i have a matter about positioning the node.
I’ve set the muzzle’s local translation to (0,0,10) and i don’t rotate them,but they slide from weapon’s pivot to (0,0,10) based on how i rotate the camera (and subsequently the weapon).

As i said,i just move and rotate the weapon’s node when i move the camera and i don’t understand why the distance between muzzle flashes and the weapon is not constant even if i don’t apply translation to muzzle flashes’ node.

I can’t post code right now,i promise i’ll post it when i’ll get to the IDE,but i explained the code i use,how can i handle the parent-child state?

EDIT:Here it is

weapon=(Node) weap; weapon.setName("Weapon"); weapon.setShadowMode(ShadowMode.Receive); node.attachChild(weapon); muzzleFlashNode=(Node) weapon.getChild("muzzleflash"); muzzleFlashNode.attachChild(muzzleFlash);

^Declare nodes when i switch weapon. I take muzzle flash position from a ghost child node that i place in blender.

camRot.toAngles(rot); weapon.setLocalTranslation(Weap.get1Offset().add(new Vector3f(-.7f+xMov+wMov,- FastMath.sin(rot[0])*2+yMov-FastMath.abs(wMov)/2,zMov))); weapon.setLocalRotation(new Quaternion(0,camRot.getY(),-camRot.getZ(),0));

^Weapon displacement on player’s tick.

Try removing the last two lines completely from update and just set the local translation of the child to 0,0,1 once in init.

http://wiki.jmonkeyengine.org/doku.php/jme3:scenegraph_for_dummies

Already tried.

The muzzle seems to not move but the weapon doesn’t rotate with the camera and it makes impossible to have and fps-like hud.

What is muzzleFlash?

http://avophilosophies.net/wordpress/wp-content/uploads/2013/11/125microcan.jpg

I know what “muzzle flash” is… but what I don’t know is what the magic unexplained variable “muzzleFlash” is in OP’s code. Is it a geometry is it a node is it a particle emitter? Ahah… important, methinks.

…but man, playing code-20-questions is even less fun with the peanut gallery chiming in. :wink:

Please look at the tutorial I linked. If you rotate the node its connected to and only set the child local translation whatever you experience exactly is probably easily explained with the info in the tutorial.

Oh wow haha well I didn’t know what muzzle flashes were for a long time :wink:

Anyway I guess it’s a particle emitter as he wrote that his particles are ok but well you can never know what it really is

Thanks everyone,i think i just solved.

The problem was the rotating line in the tick,so now i just make:

                weapon.setLocalRotation(new Quaternion().fromAngles(rot[0],0,0));

Where rot is the rotation in angles,so i can use just one axe without using Quaternions as i’m an Ubuntu.