to select 3d objects by the arrow keys

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kohl
:warning: Old Version Published before Godot 3 was released.

Hello
How do I get the node of a 3D object closer to the top right corner of the screen?

I need to create a way to select the first element of the game with the keyboard’s directional keys, then click again on some keyboard’s directional key, select the closest object of the selected object …

I am studying about raycast, but I have not yet found a way to use it for this

Thank you.


Selectable game boxes. The top box would be the first to be selected when you click the left directional button on the keyboard
enter image description here

i think that its less about raycasts and vectors and more about mapping the nodes on the game screen… I think you can achieve what you want(or at least what i think you want) by mapping the objects on the screen by a 2d grid on the screen ( aka if you look straight down it will be different from looking from the left or the right ) and by doing so you can move between them to what appears to be closest/farthest on the screen ( because you reduce on axis that is perpendicular to the screen and the eliminates the distance on it ) .

rustyStriker | 2017-12-22 17:34

I do not know this way, but I’ll search. But since it is a physics game, objects can change positions during the game.
But in summary, the user must be able to select which object he will interact via the directional buttons of the keyboard or the joystick.

Kohl | 2017-12-22 17:51

do you want it to be constantly updating( aka when something moves it will get a new position on the 2d grid )? if so you can just update it every frame or couple of frames(if it takes too much to do so every frame)

rustyStriker | 2017-12-22 18:04

I do not need it to be updated constantly, I need to run this “search” for the nearest “box” only when the user presses a directional button.

Kohl | 2017-12-22 18:09

yeah yeah of course… but I think you can “cheat” it using the position Vector and the camera facing vector(or whatever it is) and simply “take” the part that is perpendicular to the camera’s vector and that way you can get a 2d position i believe(ofc you will need to manipulate it a bit more)

rustyStriker | 2017-12-22 18:51

I think I understood, I’m going to search this way. ty

Kohl | 2017-12-22 19:03