0 votes

Hi there I would like to know if there is any equivalent lengthdir_x or lengthdir_y I just need to set up a viewport x and y with them ?

in Engine by (27 points)
edited by

What is lengthdir_x and lengthdir_y?

lengthdirx and lengthdiry are functions to determine the x and y in a direction.
example: https://docs.yoyogames.com/source/dadiospice/002_reference/maths/real%20valued%20functions/lengthdir_image.png.

1 Answer

+1 vote
Best answer

Godot has vector types, Vector2 and Vector3. They can represent points, directions or sizes, in 2D and 3D. You can get the individual components by writing the_vector.x or the_vector.y. They can be negative depending on what the vector represents. If it's a size, it will always be positive. If it's a direction or a point, it can be negative.

For example, the size of a texture is obtained with its get_size() function, which you call like the_texture.get_size(). It returns a Vector2. That means the width of the texture is the_texture.get_size().x. There are lots of other properties in Godot working this way.

In case you want the size of the screen, you can get it with get_viewport().get_size(), where get_size() also returns a Vector2. In the case of viewports, it can also be shortened as .size: https://docs.godotengine.org/en/3.1/classes/class_viewport.html#class-viewport-property-size

If you need something else, please explain better^^

Also, this may be useful to learn more about vectors: https://docs.godotengine.org/en/3.1/tutorials/math/vector_math.html#vector-math

by (29,120 points)
selected by
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.