+1 vote

Because when enemies die I want them to reborn within rectangle

Sorry for my bad english :D

in Engine by (30 points)

What kind of object is the rectangle?

Thank you for your anwser.
Just like a window. Sorry i don't know what kind of this rectangle called in english
but i have got an idea
just put position2d node to the top left corner and bottom right corner
and then get global position of them and random between position x and y of 2 node

var random_x = rand_range(position1.x,position2.x)
var random_y = rand_range(position1.y,position2.y)

1 Answer

0 votes

You could use the Rect2() object.
It is a rectangle defined by 2 vectors. The first Vector specifies the origin, and the second Vector specifies the opposite (diagonal) corner of the Rectangle.
This object would be useful to you as it contains methods to test for points within its perimeter.

by (14 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.