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 ?

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 ?

*x and lengthdir*y 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 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

- All categories
- Engine 33,552