I followed a tutorial to create a rearview camera and it works well but with one weird issue. If the camera is in an overlay scene, it only works after I have run the game once. So I open Blender and run the game = doesn’t work. Run the game again (without closing Blender) and it works fine.
I moved the plane with the rendered texture to the main scene and it works fine on the first run, so it is only an issue with the overlay scene. Unfortunately I REALLY need it on the overlay.
Here are the 2 scripts I use.
Initialize the rearview:
def RearviewInit(cont):
own = cont.owner
for i in g.getSceneList():
if i.name == "Scene":
scene = i
cam = scene.objects["RearviewCam"]
matID = texture.materialID(own, "MARender")
renderToTexture = texture.Texture(own, matID)
renderToTexture.source = texture.ImageRender(scene,cam)
own["RenderToTexture"] = renderToTexture
Refresh the texture (runs every frame)
def RearviewTex(cont):
own = cont.owner
own["RenderToTexture"].refresh(True)
Anyone know why that won’t run the first time but every subsequent time it runs fine?