Hey guys, my problem is quite simple - but I don’t know how to fix it.

I have two scenes…
-My main scene (where I’m in a first person camera mode)
-My heads up display (which is connected to my main scene as scene overlay)

My problem is - when I use the drawLine() method in my HUD scene, it doesn’t position the lines I draw where I’m looking (through the camera) but in the actual coordinates of my main scene. . . This is VERY strange, how do I work around this?

NOTE: As you can see in the images ( one is my HUD scene overlay with just a square made with drawLine() method, and one within my main game ) The square isn’t in the center of my camera like I want it to be - instead it’s on the floor - or the positions I gave it for my HUD SCENE OVERLAY… Not my main scene… Anyone… someone… please, help!

Also - I do not want to use a plane and have it’s material as wireframe to just give the same effect - I want to use drawLine. Anyone know how to fix my problem?

### Attachments

It seems that wire is being rendered using the model matrix from the main scene, multiplying your bottom_left ect vectors by the inverse of the the main scene’s model matrix and than by the hud scene’s model matrix (or something like that) should hopefully solve it, use this instead:

``````import bge
from mathutils import *

main_cam = [scn for scn in bge.logic.getSceneList() if scn.name == "main"][0].active_camera
hud_cam = bge.logic.getCurrentScene().active_camera

Mi = main_cam.modelview_matrix.copy().inverted()
M = hud_cam.modelview_matrix

top_left = Vector([0, 0, 0, 0]) * Mi * M
bottom_left = Vector([0, -1, 0, 0]) * Mi * M
bottom_right = Vector([1, -1, 0, 0]) * Mi * M
top_right = Vector([1, 0, 0, 0]) * Mi * M

color = [0, 0,0]

bge.render.drawLine(top_left[:3], bottom_left[:3], color)
bge.render.drawLine(bottom_left[:3], bottom_right[:3], color)
bge.render.drawLine(bottom_right[:3], top_right[:3], color)
bge.render.drawLine(top_right[:3], top_left[:3], color)
``````

Also, if you are making a hud, consider using the bgui.

It runs … and now it orientates itself with the main camera - but doesn’t move with it - as I am moving…

Since - I move in the game - the square is just staying there - orientating with the main camera in the main scene - but not moving with it -

Are You sure You draw in the right scene???

The best way to be sure is to draw from a function connected to the scenes post_draw callback. If You have a function named my_draw() do:

right_scene.post_draw.append(my_draw)

NOTE! No () after the function name. You can use a method from a object as callback, just use obj.method without () instead of my_draw.

It draws it in both scenes since it’s just a scene overlay…

You my friend - are a GENIUS!

.post_draw = [HALELUAH!]

I love the .post_draw thingy. THIS THREAD IS SOLVED! THANKS ALL FOR THE HELP!