Hey everyone.
I'm working on my first game and I'm kind of aiming for the moon. I know it's not smart but let's just say that right now I'm in the trying to figure out how to make each game mechanic or system from scratch. Learning how to code, learning how to create blender objects and learning everything along the way.
With the tools online I've been able to do a lot but I'm stumbling on a targetting system that works. I've added a screenshot of the game + some of the background information for you to check out. As well as the code I'm going to talk about.
I've added the script Targeting.gd script to an Area3D note that has a cylinder shape3D collision shape as a child parent. Every frame I calculate which overlapping bodies on collision layer 2 are within the Area3D and then after clicking "target" key input (right mouse button) I print out some of the stuff I thought I could use to make the targeting system work.
What I want it to do is calculate which object on screen is the closest to the middle (think Zelda or RDR2 style) that forces the camera to pan over to it, once close enough gives an option to talk or to do things like break a vase or whatever else I can think off.
I got to calculating the position of the objects in that Area3D but then I learned that the vector3 information is useless once trying to calculate how it looks on screen. I got to calculating the center point of the camera view which I think I managed.
When now trying to use that same strategy to print out the vector2 position of objects inside the array "detection" in a viewport I get stuck on how to do it. First of all, with everything I do I totally forget to calculate whether an object is even on screen or not. Then, I get loads of issues with vector3 positions not being suited for a camera3.unproject_position() function... I'm stuck.
So yeah if anyone has a tutorial or clue how to get it to work let me know! 😆😆