0 votes

So far, everything I have done resulted in an error with this version giving me this error:
Attempt to call function 'position' in base 'null instance' on a null instance.

extends Position2D


var rngx = RandomNumberGenerator.new()
var rngy = RandomNumberGenerator.new()
func _on_Button_button_down() -> void:
    var x = int(rngx.randf_range(0,1024))
    var y = int(rngy.randf_range(0,600))
    $self.position(x,y)

Just in case, here's my nodes so far

What should I do?

Godot version Godot 3.5
in Engine by (18 points)

1 Answer

0 votes

Your error happened because if incorrect reference to position 2d node. No $ is needed when You use self

about buttons itself, all control nodes use rect_position instead of position

by (7,925 points)
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.