0
Answered

Change Intensity Multiplier via Action

Cr4shBarcode 8 months ago in Game Creator updated by Marti (Lead Developer) 8 months ago 4

I'm making a transition from day to night in my game. The Intensity Multiplier, located in the Lighting options, is integral to this.

By increasing it, I can make a scene look like daytime without the need to add a bunch of cumbersome lights. 

Decrease it and things become pitch dark, the only light coming from the ones I've baked into the scene.

If I can't alter the value via an action, I'll be forced to create an entirely separate scene, just so I can have a different Intensity Multiplier value for it.

Despite there being a couple YouTube tutorials that work with the Intensity Multiplier, I need to find a script that works with Game Creator.

Unity version:
Game Creator version:

Answer

Answer
Answered

You'll need a reference to the Light component as well as a public float variable to se the intensity. Once you have that, it's all a matter of setting the value to the "intensity" property of your Light reference. Here's the code:

namespace GameCreator.Core
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

[AddComponentMenu("")]
public class IntensityMultiplier : IAction
{
public Light light;
public float lightingIntensity = 0f;

public override bool InstantExecute(GameObject target, IAction[] actions, int index)
{
this.light.intensity = this.lightingIntensity;
return true;
}

#if UNITY_EDITOR
public static new string NAME = "Custom/IntensityMultiplier";
private const string NODE_TITLE = "Change the value of Unity's Intensity Multiplier to brighten or darken the ambient lighting of a scene";
#endif
}
}
BAD, I'M UNSATISFIED

Sorry, I'm not looking to change the intensity of a random light object. I'm talking about environment lighting. The Intensity Multiplier isn't attached to any one single light--I've highlighted it in the images above. It's not attached to the Directional Light, or any Point Lights, etc. This is the only clue I could find as to what to put in the script:

Satisfaction mark by Cr4shBarcode 8 months ago
Under review

You'll need to create a custom Action for this. Not sure if you're familiar with programming, but even if you're just the slightest, it should be fairly easy to do. You can follow the instructions set at https://docs.gamecreator.io/game-creator/systems/game-creator-api/custom-actions.

If you're not familiar with programming, someone from the Discord might be up to lend you a hand. If you have any questions on how to create the Action, feel free to continue below these lines.

This is as far as I got. I'm not sure what to do next. I just want an action that sets the value of the Intensity Multiplier.

namespace GameCreator.Core
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

[AddComponentMenu("")]
public class IntensityMultiplier : IAction
{
public int LightingValue = 0;
public static float ambientIntensity;


public override bool InstantExecute(GameObject target, IAction[] actions, int index)
{
Debug.Log(this.example);
return true;
}

#if UNITY_EDITOR
public static new string NAME = "Custom/IntensityMultiplier";
private const string NODE_TITLE = "Change the value of Unity's Intensity Multiplier to brighten or darken the ambient lighting of a scene";
#endif
}
}

Answer
Answered

You'll need a reference to the Light component as well as a public float variable to se the intensity. Once you have that, it's all a matter of setting the value to the "intensity" property of your Light reference. Here's the code:

namespace GameCreator.Core
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

[AddComponentMenu("")]
public class IntensityMultiplier : IAction
{
public Light light;
public float lightingIntensity = 0f;

public override bool InstantExecute(GameObject target, IAction[] actions, int index)
{
this.light.intensity = this.lightingIntensity;
return true;
}

#if UNITY_EDITOR
public static new string NAME = "Custom/IntensityMultiplier";
private const string NODE_TITLE = "Change the value of Unity's Intensity Multiplier to brighten or darken the ambient lighting of a scene";
#endif
}
}

In that case, you can simply change this

this.light.intensity = this.lightingIntensity;


For the following:

RenderSettings.ambientIntensity = this.lightIntensity;


You can also safely remove the "public Light light" line, since you're not going to be using a Light component anymore.