The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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

enter image description here

enter image description here

Godot version v3.3.2 stable official
in Engine by (26 points)

2 Answers

+1 vote

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

by (2,018 points)

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

+1 vote

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

by (224 points)
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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.