0 votes

I'm trying to make a game where you click on an object and it will change places on the screen using a random number generator. How do make the random number generator work? Also I just started coding, which is why everything is probably wrong. lol

 extends RigidBody2D

    #variables
    var base_speed = 200
    var acceleration = 50
    var scale_variation = 2
    var motion = Vector2()

    func _ready():
        randomize()

    # Clicks
    func _input(event):

         RandomNumberGenerator
            var random_motiony = (randi_range(1,600))
            var random_motionx = (randi_range(1,1024))

            if event.type("lmb_click"):
                if $UFO_collision:
                    motion.y = random_motiony
                    motion.x = random_motionx
                    Transform2D(scale_variation) 

error(16,34): Method 'randirange' is not declared in the current class.
Condition' _debug
parseerrline >=0' is true.returned: _null

in Engine by (12 points)

1 Answer

0 votes

Just write:

var random_motiony = int(rand_range(1,600))
by (144 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 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.