I have a gun object that is attached to an enemy character as a child of the hand object. There is an empty child object located at the end of the barrel that I am trying to use to spawn the bullets. For some reason the Y value of the transform.position for the spawning location is changing randomly, even though in the scene inspector it appears to be staying in the exact same position. I am getting the Y values outputted to the console with this line of code in a script attached to the empty object:
When I move the gun object so that it is a child of the parent prefab (rather than the hand) and just sticking out of the enemy’s chest then this issue doesn’t seem to be a problem and the values outputted to the console match the apparent position of the object. Does anyone have any guidance on how to go about solving this issue?
I have attached a screenshot from the editor showing how things are set up if that is any help.