How to change light color in response of an event?

I am trying to change the color of a light after a HttpResponse or after a broadcast event.

In 1.9 or 1.8.1 I have the same issue. I am using this command in Lua:

LightComponentRequestBus.Event.SetColor(self.entityId, Vector3(0,200,0))

And the error is the same in 1.9 and 1.8.1:

C3DEngine:RegisterEntity should only be called on main thread. Save Level Before Exiting the Editor?

Thank you!

I’m checking with a tech to see if they know can help you out.


tks a lot!

@Binky_LY any news about this? tks!

Hello @aridias,

Can you post your Lua code? We’d like to investigate which Bus or API call is causing this.

Thank you.

Hello @aridias,

I was able to reproduce the issue you were experiencing. For some reason changing the light color seems to destroy the light render and then recreate it and as such seems to happen on the wrong thread. I’ve informed the team about this. In the meantime, I’d recommend having two lights set up with the colors that you need and switch them on/off based on what you want to accomplish.

Edit: Alternatively, you can apply the following changes to HttpClientComponent.cpp which would execute the callback on the main thread:

  1. Add the following include:
#include <AzCore/Component/TickBus.h>
  1. Replace MakeHttpRequest function with the following:
* HttpClientComponentRequestBus::Handler
void HttpClientComponent::MakeHttpRequest(AZStd::string url, AZStd::string method, AZStd::string jsonBody)
auto job = aznew HttpRequestJob(true, ServiceJob::GetDefaultConfig(),
[this](int responseCode, AZStd::string content)
AZ::EntityId entityId = m_entity->GetId();
AZStd::function<void()> requestCallback = [entityId, responseCode, content]() {
EBUS_EVENT_ID(entityId, HttpClientComponentNotificationBus, OnHttpRequestSuccess, responseCode, content);
EBUS_QUEUE_FUNCTION(AZ::TickBus, requestCallback);
[this](int responseCode)
AZ::EntityId entityId = m_entity->GetId();
AZStd::function<void()> requestCallback = [entityId, responseCode]() {
EBUS_EVENT_ID(entityId, HttpClientComponentNotificationBus, OnHttpRequestFailure, responseCode);
EBUS_QUEUE_FUNCTION(AZ::TickBus, requestCallback);

Hope that helps.

LightComponentRequestBus.Event.SetColor(self.Properties.Light, Vector3(200,0,0))
still in version 1.8.1