Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Spot light disappears when it turns precisely 180 degrees

Discussion in '2D' started by lightphaser, Aug 5, 2022.

  1. lightphaser

    lightphaser

    Joined:
    Feb 14, 2019
    Posts:
    3
    Hi,

    I have found a problem for which I could not find any solution yet, so I though I will ask it here.

    I have a 2D scene with a spaceship sprite, a spot light attached to it as child and some enemy ufo objects all around it in every direction. The light is above the sprites and is nicely visible on the spaceship and the ufo objects as well. It all is good, until I rotate the spaceship sprite (and the light along with it) along the Z axis precisely 180 degrees, when at that moment the light disappears from the ufo objects (but not from its parent spaceship). If I rotate the sprite again a tiny little bit into either direction, then the light becomes visible again on the ufo objects.

    Parameters of the UFO sprite:
    Its game object's Z position: 0
    Color: white
    Flip: no flip checked
    Draw mode: simple
    Mask interaction: none
    Sprite sort point: center
    Material: Just a standard unity Sprites/Diffuse material with white tint, with no other changes to the material.
    Sorting layer: Default
    Order in layer: 0

    Light:
    Its game object's Z position: -2
    Type: Spot
    Range: 5
    Spot angle: 150
    Color: white
    Mode: Realtime
    Intensity: 6
    Indirect multiplier: 1
    Shadow type: No shadows
    Cookie: None
    Draw halo: not checked
    Flare: None
    Render mode: Auto
    Culling mask: Mixed... (Only those two layers are checked where the UFOs and Spaceship are located)

    I have tried several things like changing the Light's mode parameter to other values, changing the render mode to important, changing combinations of culling mask layers but without any success.

    So I can't figure it out, why is there no light on the UFO object when the light is rotated into precisely 180 degree only. The light is still visible at that position on its parent Spaceship object, it is missing only from the UFO and only in 180 degree position.

    Please, do you have any idea what might cause this problem?
    Thank you very much in advance!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    Make a blank scene, drop your sprite in, drop your light in, press PLAY

    Now rotate the sprite using the editor. Does the same thing happen?
     
  3. lightphaser

    lightphaser

    Joined:
    Feb 14, 2019
    Posts:
    3
    Thank you for the tip, however in the meantime I have found what caused the issue.
    It seems that in my logic at the beginning where I instantiated the GameObject I modified the transform.rotate in order to put the object into the desired orientation, instead of using the proper method of Quaternions.

    So, after replacing the modification of transform.right by Quaternions, everything got solved! :)