Saranoske
(Boris Koštel)
November 2, 2020, 12:51am
1
I’m trying to change the focal length of a camera in-game.
I have tried this:
cameraFL = bpy.data.cameras["Camera"]
cameraFL.lens = 11.0
This doesn’t do anything in-game but changes the focal length of the camera in Blender when I stop the game.
Maybe it doesn’t work when I’m combining it with Class KX.
Also when I try to change the camera in-game, it doesn’t work.
bpy.context.scene.camera = bpy.data.objects["CameraLIFT"]
This changes the camera after I stop the game in Blender.
John_tgh
(John_tgh)
November 2, 2020, 5:27pm
2
I think the BPY module is not for working in the game engine, but the editor.
I can’t test this right now, but I think this would work - run it from a camera:
from bge import logic
cont = logic.getCurrentController()
cam = cont.owner
cam.lens = 11.0
Edit: Replaced “fov” with “lens”.
1 Like
John_tgh
(John_tgh)
November 2, 2020, 10:03pm
4
One is glad to have been of service Ø__^ If I may ask, what are you trying to create?
Saranoske
(Boris Koštel)
November 2, 2020, 10:06pm
5
I wanted to create a zoom in and zoom out for specific locations in-game.
In this case, looking at what kind of items are on a shelf.
John_tgh
(John_tgh)
November 2, 2020, 10:10pm
6
Ooooh! Interesting! Using the camera effectively is a very good way to distinguish your game : D Best of luck!
1 Like