0 votes

I create a Panel at runtime using this code:

var tempPanel = Panel.new()

then i want to change the position of the Panel. I tried this:

tempPanel.position = Vector2(x, y) # Where x and y are forloop variables.

But then i get this error:

Invalid set index 'position' (on base: 'Panel') with value of type 'Vector2'

Maybe you could help me with this?

Godot version 3.2.3 (stable)
in Engine by (42 points)

1 Answer

+1 vote
Best answer

Node2Ds have a position property. Your code doesn't work because a Panel isn't a Node2D. Panels are Controls. Controls have similar property called rect_position.

tempPanel.rect_position = Vector2(x, y)
by (365 points)
selected by

Thanks alot, that worked flawless!

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