This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Set Position changing position of other object

blackarckblackarck Posts: 4Member

Hi Guys,
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.

  1. var xgunpos = get_parent().get_node("Car/Carbody/gun").get_global_pos().x
  2. var ygunpos = get_parent().get_node("Car/Carbody/gun").get_global_pos().y
  3. print("xpos",xgunpos," ypos",ygunpos)
  4. b.set_pos(Vector2(450,378))
  5. b.set_pos(Vector2(xgunpos,ygunpos))


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.