How to get Streetlights working?

Hey there, sorry if this seems hastily put together, I’ve spent the last 6 or so hours trying to get this to work. I have a streetlight object that I wish to have work the same way the vanilla street lights do, so essentially they require power to turn on and off, and when doing so their light source and emission turn off as well.

I haven’t been able to find any examples or documentation on this, but the problem I’m running into seems to be related to the Interactability_Emission property. With the way my lightpost is currently setup in Unity (Image at the bottom), I am able to get the ragdoll to work, as well as the light to toggle, but the emission seems to always be on for the material.

It seems like the only way to get this to work is if the Model_0 isn’t a child of the “Alive” gameobject, but doing this means that it will no longer be distructable and won’t ragdoll. It seems like I’m in a bit of a dichotomy, where either the streetlight is destructable but won’t toggle emissions, OR, it will toggle emissions and won’t be destructable.

I’m sure the issue has something to do with my structure in Unity, but without example assets to compare to I’m really at a loss for what I’m doing wrong. Any advice would be great, thank you!

(as a note; I tried having the “Alive” game object contain the mesh renderer and filter, but doing that still doesn’t toggle the emission on or off)

I made an example of a door with Activation Event hooks on both Alive and Dead to control Root activity.

I see, so it aeems like I need a root gameobject for this.

So should i have the Model_0 and Light as a child of the root? Also will that still allow it to be destructable when alive, and also toggle the light and emission there?

That’s overkill. Root is a common name for rigged animation components. In this case you already have a gameobject that acts like root: Object. I’m assuming the problem is you’re missing some things in your object’s dat file. Double check against Vanilla’s streetlight’s dat and make sure you have lines about toggles.

Interactability Binary_State
Interactability_Hint Switch
Interactability_Power Stay

You can use an activation hook, but it’s not really necessary considering the functionality already exists.

For future reference, the only times you really need to worry about object hierarchy is activations (alive, dead, toggle) and character animation.

Yeah i have all of these in the .dat file for object. My main question is that the toggle doesnt seem to work for interactability_emission unless Model_0 is a direct child of the Object gameobject.

The problem is that if the model isnt nested under alive then it wont ragdoll when destroyed.

I assume its similar to Use_nightlight_script, where the script specifically looks for an object called “light”, but im not really sure what exactly Interactability_Emission is looking for. Obviously its not just toggling the emission property of any material in the file, since it only seems to work when the model_0 is at the front of the object.

So im really just at a loss at this point, itd be amazing to actually have a look at the script that controls interactability_emission, but until that day comes its more trial and error until i reinvent the wheel.

This is how one of my streetlights are setup. Toggle is a child of alive.


I experimented, the door and the lamp are different production processes, kvc.6 is right.
You need to drag Toggle into Alive and add a new model to Ragdoll.

I’ve seen people ask about this a few times. We’ll see about getting an example streetlamp (or similar object) added to the ExampleAssets.unitypackage as part of a future update.

That would be great, I used the example given above and managed to get my streetlights to work, but it would be great to see lights in the example files, especially the ones using the nightlight script.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.