Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize alarm Lamp in Unity3D

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Today, I will talk to you about how to realize the alarm light in Unity3D. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.

Function description: the role enters a dangerous state and triggers the alarm light. The light turns on, gradually brightens, the brightness reaches the maximum, and gradually darkens. The character is out of danger and the alarm light is turned off. At the same time trigger the alarm music on and off.

1. First add an alarm light to the scene. (Alarm Light) 2. Set up its Transfrom,Tag and so on. 3. It is not enabled by default, and the invite value is 0. 0. The color is generally dark red RGB (70pl 0pl 0). 4.Culling Mask is Everying, does not participate in baking, Mode is Realtime.

Add a script:

Public float fadeSpeed=2f; / / Light Luminance gradient Speed public float highIntensity=4f; / / Luminance maximum public float highIntensity=0f; / / Luminance minimum public float changeMargin=0.2f; / / Mark for changing target brightness public bool alarmOn; / / whether or not alarm light is turned on private float targetIntensity; / / target brightness, toward the changed brightness private Light alarmLight; / / alarm light object void Awake () {alarmLight=GetComponent (); alarmLight.intensity=0; / / initial measurement is 0 targetIntensity=highIntensity / / Target is maximum luminance} / / Toggle target luminance void ChangeTargetIntensity () {if (Mathf.Abs (targetIntensity-alarmLight.intensity))

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report