Position2D not take the right position

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Juwu

I put a Position2D for the projectile for the player on my game, but the position that I put wasn’t the original, the position stays a little down and right from the original

:bust_in_silhouette: Reply From: magicalogic

Just click on the position2d node in the scene setup and press w then click and drag to move it into position.

I know how to move the node, the problem is that the position who the projectile spawn is not the I put

Juwu | 2021-06-11 14:59

:bust_in_silhouette: Reply From: theMX89

the problem coud may be in your code where the projectile gets moved slightly

extends Node2D
var speed = 10
var ball = false
var up = false
var down = false
var left = false 
var right = false
var proj = preload('res://Scenes/Ball.tscn')
func _process(delta):
move()
stop() 


func move():
 if Input.is_action_pressed("ui_right"):
	position.x += speed 
	right = true
	left = false
	down = false
	up = false
	
	pass

if Input.is_action_pressed("ui_left"):
	position.x -= speed
	left = true
	right = false
	down = false
	up = false
			
	pass
	
if Input.is_action_pressed("ui_up"):
	position.y -= speed
	up = true
	left = false
	down = false
	right = false
	pass
	
if Input.is_action_pressed("ui_down"):
	position.y += speed
	down = true
	left = false
	right = false
	up = false
	pass


if Input.is_action_just_pressed("ui_select"):
	var tiro = proj.instance()
	get_parent().add_child(tiro)
	tiro.position = $Player_2d/Position2D.global_position
	

func stop():
if position.x <= 20:
	position.x = 20

elif position.x >= 1280:
	position.x = 1280
	
if position.y <= 0:
	position.y = 0

elif position.y >= 720:
	position.y = 720

the code

Juwu | 2021-06-11 15:14