I have keyframed the scale of the camera in my scene so that it always does kind of a zoom in and zoom out to an object at the beginning of the scene. Using the logic bricks I have established an "always" sensor with an "action" controller linking that specific action but it isn't working! I have read this post and tried it but still is not working. Is it even posible to do it in the BGE? I am using v 2.72
Animating the orthographic scale the way you do it is not possible. You can however do this via python using
bge.logic.getCurrentScene().objects["Your_Camera"].ortho_scale = your_value.
Your_Camera has to be the name of the camera whose orthographic scale you want to adjust.
your_value has to be the desired focal length. That can be a float between 0.01 and 4000.0. Following is an example of zooming in to a value of 5.0. Therefore the orthographic scale at the start needs to be above 5.0.
import bge #getting the camera object called 'Camera' cam = bge.logic.getCurrentScene().objects["Camera"] #while the orthografic scale is above 5.0 the script reduces it by 0.5 everytime the script controller is activated if cam.ortho_scale > 5.0: cam.ortho_scale -= 0.5
Now you can write a script that does what you want. Here's another example where we are zooming in first and when this has finished we are zooming out again.
import bge #getting the camera object called 'Camera' cam = bge.logic.getCurrentScene().objects["Camera"] #while the orthografic scale is above 5.0 the script reduces it by 0.5 everytime the script controller is activated, if there's a game property with the name 'zoomed_in' it won't zoom in again if cam.ortho_scale > 5.0 and not "zoomed_in" in cam: cam.ortho_scale -= 0.5 #if the cam is already zoomed in and the ortho_scale at a value of 5.0 the camera is zooming out again, adds the game property 'zoomed_in' to the camera to prevent it from zooming in again elif cam.ortho_scale < 23.0: cam["zoomed_in"] = True cam.ortho_scale += 0.5