Set Position changing position of other object
Below is my code that i am using to set position of my spawned bullets. I want the position of the bullet to stay with position of the gun, for that I am fetching gun's position ( that is not coming out right as well coordinates are >600 for a 600*400 viewport). Anyways main problem is with line 5, If I only use line 4 without 5 it works like a charm since those are hard coded figures. everything works like they support too.
But if I use dynamic position setting using line 5, then the main object i.e. Car ( directly under node2) starting rotating on the main screen even though its not related to object b.
Any suggestions on why it might be doing that.
- var xgunpos = get_parent().get_node("Car/Carbody/gun").get_global_pos().x
- var ygunpos = get_parent().get_node("Car/Carbody/gun").get_global_pos().y
- print("xpos",xgunpos," ypos",ygunpos)