Ok so i have a code that i got from the site to control my camera the way i wanted it to move. It has Pan limits built into it though and i need it to change for each map. so is there a way without changing too much code that i can call a variable from another file?
just to show you (File 1):
import direct.directbase.DirectStart
from CameraHandlerClass import CameraHandler
class World(DirectObject):
def __init__(self):
#Task to add camera controls for the camera
camHandler = CameraHandler()
run()
Of course i cut out all my code execpt my current call. This calls CameraHandlerClass.py and in that code there is this (File 2):
from direct.showbase import DirectObject
from pandac.PandaModules import Vec3,Vec2
import math
class CameraHandler(DirectObject.DirectObject):
def __init__(self):
base.camera.setPos(0,0,50)
base.camera.lookAt(0,0,0)
# Gives the camera an initial position and rotation.
self.mx,self.my=0,0
# Sets up variables for storing the mouse coordinates
self.orbiting=False
# A boolean variable for specifying whether the camera is in orbiting mode. Orbiting mode refers to when the camera is being moved
# because the user is holding down the right mouse button.
self.target=Vec3()
# sets up a vector variable for the camera's target. The target will be the coordinates that the camera is currently focusing on.
self.camDist = 40
# A variable that will determine how far the camera is from it's target focus
self.panRateDivisor = 20
# This variable is used as a divisor when calculating how far to move the camera when panning. Higher numbers will yield slower panning
# and lower numbers will yield faster panning. This must not be set to 0.
self.panZoneSize = .10
# This variable controls how close the mouse cursor needs to be to the edge of the screen to start panning the camera. It must be less than 1,
# and I recommend keeping it less than .2
self.panLimitsX = Vec2(-20, 20)
self.panLimitsY = Vec2(-20, 20)
# These two vairables will serve as limits for how far the camera can pan, so you don't scroll away from the map.
What i want to do is call panLimitsX and Y as well as base.camera.setPos and base.camera.lookAt from the first code is this possible to do this? and if so how do i change the code to do this? I have tried to figure it out and either im just over compicating this or something needs to be added so i can do this