1
$\begingroup$

enter image description here

How would I incorporate the ortho zoom to my mouse wheel?

This seems close to what I need, but I don't know why it's not working.

import bge

cont = bge.logic.getCurrentController()
cam = bge.logic.getCurrentScene().objects['Camera']

if not "DefaultFOVset" in cont.owner:
    cam.ortho_scale = 20
    cont.owner["DefaultFOVset"] = True

FOV = cam.ortho_scale

if cont.sensors["MWHEELUP"].positive:
    if FOV < 20:
        FOV += 1 # linear increase
        FOV /= 0.9 # exponential increase
    if FOV > 20:
        FOV = 20
elif cont.sensors["MWHEELDOWN"].positive::
    if FOV > 10:
        FOV -= 1
        FOV *= 0.9
    if FOV < 10:
        FOV = 10

cam.ortho_scale = FOV

Here's another one, I can only get it to zoom out. https://blender.stackexchange.com/a/58556/37524

$\endgroup$
1
$\begingroup$
  • Typo on the line 18 positive:: to positive:

  • You need 2 sensors for each of detect wheel up and down. And the sensors have to be connected to the python controller. This is why you got only one of zoom out or in.

  • You have to make the names in blender to be consistent with the names in the script, also the script file name.screen shot

Advice: You can open console from menu Window > Toggle System Console. The console shows error messages from BGE when BGE is running. Be carful, closing the console window closes whole blender.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.