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.