0

i want to make it so when something is true then the directional lighting will have a different angle. i tried something like this:

drlight = DirectionalLight(parent=pivot, y=3, z= -6, shadows=True, rotation=(0, 45, 
drlight2 = DirectionalLight(parent=pivot,y=100, z=120, shadows=True, rotation=(45, -45, 45))
drlight.enabled = True
drlight2.enabled = False

and then change it in some if:

    def input(self, key):
    if self.hovered:
        if key == 'left mouse down':
            if animloaded:
                drlight.enabled = True
                drlight.enabled = False

unfortunately it didnt work. if anyone knows what to do pls help

iceneoon
  • 21
  • 3

2 Answers2

0

You're setting drlight.enabled to True and immediately back to False. Did you mean to disable drlight and enable drlight2?

Try this instead:

drlight2.enabled = True
drlight.enabled = False
pokepetter
  • 1,383
  • 5
  • 8
  • i think it was just a typo in this text but i tried to enable the other light at the start of this code but it still stays the same – iceneoon Dec 05 '22 at 19:10
  • is it even possible to enable and disable light? i know that i can destroy it with destroy() – iceneoon Dec 05 '22 at 19:17
0

i think i found the right answer to my own question! instead of swapping the lights i have made the light as a class and then change its position and rotation if something happened

class directlight1(DirectionalLight):
def __init__(self):
    super().__init__(
        parent=pivot,
        y=3,
        z=-6,
        shadows=True,
        rotation=(0, 45, 30),

    )

if animloaded:
        
   directlight1.rotation = (45,-45,45)
   directlight1.y = 100
   directlight1.z = 120
iceneoon
  • 21
  • 3