Can i get a simple object without a class from an actor?

Hi mates…

Let’s suppose i want to turn a light on from a switch,
Switch is my actor class, but light has no class, is just an object on scene, i want to access to the light from my actor class and set it’s visibility…

i can imagine i could use UPROPERTY(EditAnywhere) with a property that points to the light but still do not get what is the type for that variable, i tried USpotLightComponent , but once compiled, in my Details panel that property ask me to add a conponent, not an object from the map…

Of course i can create another actor for light so i can easily access between those classes but im not sure if this is good, i mean, I’m not sure if making the light an actor class just to set visibility is the solution

any ideas?

thanks

Hi!
Would it be, to access the Light Component of the Switch Actor? If the object is on the map it is an Actor but it can be a Component of an Actor.
Anyway, to reference map Actors/Components you can search them in the World: https://wiki.unrealengine.com/Iterat…_Faster_Search

Actor SpotLight: ASpotLight | Unreal Engine Documentation
Component SpotLight: https://api.unrealengine.com/INT/API…ent/index.html

Whats diference between spotlight as actor and spotlight as component ?..
I tried to set intensity from ASpotLight unsuccessfullly .

Actor is like a representation of a real object, such as a car or person, its features like walking or flying are made by Components.
Components are features that the object will have.

You can see that the ASpotLight has a variable SpotLightComponent (USpotLightComponent) that illuminates the scene.
In USpotLightComponent description you can read: “A spot light component emits a directional cone shaped light (Eg a Torch).”

So ASpotLight is like an “object” and USpotLightComponent is like its “functions”.

Alright, and supposing i have a Spotlight on my map, and want to access it from another actor (a switch) i tried this:



//switchMaster.h

class ASpotLight * targetSpotLight;





//switchMaster.cpp

targetSpotLight->SetIntensity(3000.0f);        //This gave me an error SetIntensity is not a function of ASpotLight..



In such case, how can i access the function from ASpotLight ?

You know ?.. on Unity i had created a group of many elements inside a class, light was included on interruptor and all was threated as a group, so light was locally managed inside the group:

LightSwitchGroup
SwitchBase
SwitchMesh
LightComponent

I just drag and drop the LightSwitchGroup prefab into scene and there i go, just put in place each object, LightSwitchGroup cointains the script to handle everything… I mean, threat light and switch as a group, else than two independant objects… this will allow me to create the light inside of switchMaster class…

can i do this on Unreal?

Thanks Again :!

I made some games using Unity before using Unreal!

1 - Error SetIntensity is not a function of ASpotLight.

ASpotLight or Actor can be thought of as a GameObject. Here you want to change the **SpotLight Component ( **USpotLightComponent ) like Unity.
It would be like this ( I have not tested ):


TargetSpotLight->SpotLightComponent->SetLightBrightness(3000.0f);

Explaining:
TargetSpotLight - Naming Convention: Coding Standard | Unreal Engine Documentation
SpotLightComponent - Variable of ASpotLight: ASpotLight | Unreal Engine Documentation
SetLightBrightness - Function of USpotLightComponent: USpotLightComponent | Unreal Engine Documentation

The documentation has helped me a lot, it’s worth looking at.

2 - On Unity…
You can do the same in Unreal, you just need to see what changes from one to the other. I think this can help:

Thanks, helped me a lot…

Cheers…