title: my get_viewport().get_mouse_position() isn't working right godot GDscript
body: <p>I'm trying to make a 2d platformer where you spawn an object and try to jump on it in the air before it falls.</p>
  <p>the problem is when I try to spawn the tile it doesn't spawn where Is the cursor at
  it adds a relative value to the position that I don't know how to get rid of it.</p>
  <p>you see when I try to instance a scene it takes the cursor position and viewport value into account but then something happens and I fount the object spawning way too far.</p>
  <p><a href="https://i.stack.imgur.com/2e5YR.png" rel="nofollow noreferrer">see where is the cursor at and where did the tile spawn</a></p>
  <p><a href="https://i.stack.imgur.com/LcjD2.png" rel="nofollow noreferrer">, same thing here</a></p>
  <p><a href="https://i.stack.imgur.com/UZYnU.png" rel="nofollow noreferrer">, and here</a></p>
  <p><a href="https://i.stack.imgur.com/jpkbX.png" rel="nofollow noreferrer">-here is how I'm grouping the nodes and scenes-</a></p>
  <p>and this is the script I'm using, it's in the player1 scene</p>
  <pre><code>extends KinematicBody2D
  # 
  var score : int = 0
  
  export var speed : int = 200
  export var jumpforce : int = 600
  export var gravity : int = 800
  
  onready var AB1 = preload(&quot;res://player1AB.tscn&quot;)
  
  var vel :Vector2 = Vector2()
  
  onready var sprite : Sprite = get_node(&quot;sprite_idile&quot;)
  onready var ui : Node = get_node(&quot;/root/mainscene1/CanvasLayer/ui&quot;)
  onready var audioplayer : Node = get_node(&quot;/root/mainscene1/Camera2D/audio_player&quot;)
  
  func _physics_process(delta):
      vel.x = 0
      # movement inputs
      if Input.is_action_pressed(&quot;move_left&quot;):
          vel.x -= speed
  
      if Input.is_action_pressed(&quot;move_right&quot;):
          vel.x += speed
  
      # applying the velcoty
      vel = move_and_slide(vel,Vector2.UP)
  
      #apllying gravty
      vel.y += gravity * delta
  
      #jump input
      if Input.is_action_just_pressed(&quot;jump&quot;) and is_on_floor():
          vel.y -= jumpforce
  
      # where the sprite facing
          if vel.x &lt; 0:
          sprite.flip_h = true
      if vel.x &gt; 0:
          sprite.flip_h = false
  
      if Input.is_action_just_pressed(&quot;restart&quot;):
          death()
  
  
  
  func death ():
      get_tree().reload_current_scene()
  
  
  
  func collect_coin (value):
      score += value
      ui.set_score_text(score)
      audioplayer.play_coin_sfx()
  
  
  func _input(event):
      if event.is_action_pressed(&quot;click&quot;):
          var ABT1 = AB1.instance()
          add_child(ABT1)
          var XN = null
          XN = get_viewport().get_mouse_position()  
          ABT1.position = XN
  </code></pre>
  <hr />
  <p>important stuff</p>
  <pre><code>onready var AB1 = preload(&quot;res://player1AB.tscn&quot;)
  
  
  
  func _input(event):
      if event.is_action_pressed(&quot;click&quot;):
          var ABT1 = AB1.instance()
          add_child(ABT1)
          var XN = null
          XN = get_viewport().get_mouse_position()  
          ABT1.position = XN
  </code></pre>
  <p>this the same problem in Godot form check it out if possible in case someone answered there</p>
  <p><a href="https://godotforums.org/discussion/27007/my-get-viewport-get-mouse-position-isnt-working-right#latest" rel="nofollow noreferrer">https://godotforums.org/discussion/27007/my-get-viewport-get-mouse-position-isnt-working-right#latest</a></p>