Is there a equivalent lengthdir_x and lengthdir_y ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ZeEndy

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 ?

What is lengthdir_x and lengthdir_y?

Zylann | 2019-10-21 00:23

lengthdir_x and lengthdir_y are functions to determine the x and y in a direction.
example: GameMaker Manual.

ZeEndy | 2019-10-22 18:09

:bust_in_silhouette: Reply From: Zylann

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: Viewport — Godot Engine (3.1) documentation in English

If you need something else, please explain better^^

Also, this may be useful to learn more about vectors: Vector math — Godot Engine (3.1) documentation in English