0 votes

I have an object that I am trying to move along the x position relative to the player's x position.

var laserPosition = Vector2()

laserPosition.x = playerPosition.x


The object disappears only when the movelocalx is in the code. Commenting it out makes the object reappear.

Any ideas why that is?

Godot version 3.3.2
in Engine by (19 points)

Try printing the position to see where it goes or checking the position in the runtime debugger.

yeah, I did this later and found that the object moving really fast off camera.
This is the code I used to fix it

var laserPosition = Vector2()

# Get player position
var playerPosition = get_parent().get_node("Player").position

# Laser position will equal player's position on X axis
laserPosition.x = playerPosition.x

position.x = laserPosition.x

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.