Forum rules - please read before posting.

Copy rotation rotates Light?

Hi all!

Hope you are doing well! So I am using a Teleport action for my character, and it has a 2D spot light object attached to it.

The skeleton has "turn root object in 3D" off -- when I move normally in any direction, the light remains a circle as expected.

However, when I teleport my character to a marker and turn it a 45 degree angle, it seems to make the light an oval -- rotating the character in 3D strangely.

Do you know why this may be?
Thank you!

«1

Comments

  • Is that to say the Marker is turned 45 degrees, or your turning the character 45 degrees after being teleported?

    Check the Y rotation of the character's root Transform - it should be kept 0 at all times if "Turn root object in 3D?" is unchecked. AC will prevent this when teleporting to Markers, though.

    What are your AC/Unity versions, and can you share screenshots of the setup as well as the root/light Inspectors together with them selected in the scene?

  • The marker is turned 45 degrees!
    Also it looks like the rotation is 45 degrees when teleporting.
    "Turn root object in 3D?" is unchecked as well!

    This is the video: https://drive.google.com/file/d/1Rorw1L3-8Wcknx7v1CqtlgjcpOe_FVbU/view?usp=sharing

  • AC: v1.79.0
    Unity: 2022.3.15f1

  • Also on another note, the lighting in general is kind of strange.

    All the lights in the scene when a specific menu turns on (called "narration") -- turn on, even though I did not interact or set them in any action list.

  • For reference, I changed the "Light"s in the "lightswitch" script to "Light2D"s instead, since the game is 2D -- unless there is a way I could use 3D lights in a 2D game and have the same effect as the video?

    Either way works! Just wondering what is the best course of action.

  • Thanks for the video. What are the rotations of the character and light once they've turned?

    The Z-rotation of 45 degrees should be OK - in 2D game, this'll point them up-right.

    If need be, you could force the light's rotation using a LateUpdate call, i.e.:

    using UnityEngine;
    public class ForceClearRotation : MonoBehaviour
    {
        void LateUpdate ()
        {
            transform.eulerAngles = Vector3.zero;
        }
    }
    

    All the lights in the scene when a specific menu turns on (called "narration") -- turn on, even though I did not interact or set them in any action list.

    The LightSwitch component uses a TurnOn function to affect its light - paste a Debug.Log in there and let's see the stacktrace from the Console when it turns on at the wrong time.

    For reference, I changed the "Light"s in the "lightswitch" script to "Light2D"s instead, since the game is 2D -- unless there is a way I could use 3D lights in a 2D game and have the same effect as the video?

    Stick to 2D lights as they're intended to be used for a 2D URP game. You needn't modify the LightSwitch script, though, as it's not referenced elsewhere. You can duplicate it and make changes / use the copy, so as to not lose such changes after updating AC.

  • Sounds good, thanks for the heads up!
    I went ahead and stuck with the current changes then for the script -- for safety, I'll see if I can duplicate it later and use the duplicate just in case.

    This is the video showing the light and character positions after it has turned: https://drive.google.com/file/d/1lSHJk09hKNb5u2zSw6UYU49KFMftl-NC/view?usp=sharing

    Is there anything I may be missing?

    I'll try debugging the other issue (the lights turning on) with what you mentioned and update this thread -- thank you!

  • This is the video showing the light and character positions after it has turned:

    Yep, looks like the character's turning when they shouldn't be - though I can't recreate the issue on my end.

    If possible, could you PM me the files involved? Hopefully it should only be a case of the scene, Managers, and the Player prefab that's needed.

  • Yeah for sure! Went ahead and DM'd :)

  • Ah by the way -- for the second issue where the global light turns on -- I tried doing a debug for the light switch in the TurnOn and TurnOff functions -- it doesn't look like that global light is even being controlled by it, which is quite strange.

    Do you know of any other places I should look?

  • Best to see screenshots of the issue, in that case.

  • edited January 22

    For sure! I went ahead and included the relevant portions in this video! @ChrisIceBox

    https://drive.google.com/file/d/1Ez4E6mHCsaA_1zdf1yd9u0K8RorXvKDf/view?usp=sharing

  • So that I'm clear: the issue is that at 0:31, the entire screen is visible?

    It looks unrelatd to the Light2D object, as the Light component is still off at that time.

    Try pausing the game at this moment, and disabling GameObjects to see which one is causing everything to be lit up.

  • Yeah that's correct! :)
    Yeah that seems to be the same -- it doesn't look like it's being switched on and off based on my logging statements.

    So I tried pausing and playing around with the Light2D object -- it seems that the "Light2D" component gets disabled right at the start, but I checked my onStart action list -- I don't use the Light2D in any of the actions.

    If I check this component and set the intensity to 0, it seems to be producing total darkness as expected.

    https://drive.google.com/file/d/1ti8oLhXR4mIoQ494JkBUPjqq_1SeSR_U/view?usp=sharing

    Here is a video where I show what I am doing! Any thoughts on where I should look next to debug this?

  • The Light2D gets disabled at the start because of its own "Enable on start" Inspector field.

    Pause the game, and see if disabling other GameObjects affects the lighting.

    Are you using a custom fade texture on your MainCamera?

  • Ah gotcha, thank you!

    Hm I tried disabling all the objects in the scene one-by-one, and nothing seems to be affecting the lighting from what I can tell.

  • We'll need to check the Actions that run before the change occurs.

    Try bypassing certain Actions to see which ones cause the issue - start with the "Camera: Fade" Actions as the issue occurs while faded out.

  • Hm, narrowed it down -- It looks like it happens when I turn off another, unrelated light in the scene before the camera fades out.

    The camera fade doesn't seem to affect it.

    Does the scene always need one light, and if so, is there a way to bypass this?

  • Is that to say that the scene is always bright if there are no active lights?

    That may be a behaviour of your render pipeline / shader - but it's not caused by AC.

    Try keeping that or another light on at all times - you can always move it off-screen to prevent it from being visible.

  • Yes that is correct!

    Ah good to know! I may do that just in case as a fix -- thank you!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.