0 votes

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

in Engine by (34 points)
edited by

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 ) .

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.

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)

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.

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)

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

Please log in or register to answer this question.

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.