Still on my little test project and I loose my hairs on this problem, launching missiles and aiming with the mouse cursor.(what a fun program!)
The grey “thing” is the start point of the missiles and the red circle is the sight visor, where the missiles should go.
So the prinpal problem is to convert x/y mouse coordinate to x/y world coordinate I suppose.
I tried a lot of scripts, with a lot of ideas finded on this forum, but nothing work, and I don’t know where to look, just a starting point for testing will be very helpfull.
There’s two api’s that might be of interest to you for your project.
This will return a point in worldspace at the location of the cursor at Z units into the scene.
This will cast a ray from the near plane of the camera that passes through a designated point.
It should be rather easy to use a combination of these to select a target point for your missiles, depending on how you have your red crosshairs implemented.
I did’nt see anything appears, so it’s difficult for me to understand how to use ScreenPointToRay (I’m a practical guy, need to see things working to understand :lol: )
I just don’t understand how to position a ray, to start from my player position (in third person view) and to end in the 3d world at the position of the aiming cross.
Is there somewhere a tutorial for using the raycast?