How made drawLine of raycast to center of screen or crosshair?

Please look the pic
The crosshair is a correct hit pos to fire but is from other scene and is a plane with picture.
But drawLine show to Ray.hiPosition

How can change this to got to center of screen or end at position of crosshair?



thanks

Cast the line till mouse center position, by grabbing the screen resolution or using 0.5,0.5 as the mouse/line end position.

But mousePosition have x,y and need vector[x,y,z] will work?

simplest way:

use an empty place it in the middle of the screen or to crosshair take the position from it yourempty.worldPosition() draw line from point to point render.drawLine(startxyz, endxyz, colorrgb)
example:


from bge import render
render.drawLine(yourempty.worldPosition(), yourtarget.worldPosition(), (1.0, 0.0, 0.0))

My crosshair is a plane with texture at position 0,0 in other scene.I addoverlayscene in logic bricks is a small red circle with other camera in other scene.the ray is on main scene.i try acess scene list and got object can support.go try to same camera of crosshair

x and y as height width, z you can set manually as the distance it should cast

Solved create a empty in same scene of crosshair then ray go to finish point in crosshair.Precision shot is player no walking if target is body ray green if target is head ray change to red color.When player walking or running no have ray cause dont have a precision target.Now working perfectly look video

Thanks