Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by PuttPutt · Dec 14, 2011 at 04:02 PM · raycastdynamiclights

Dynamic lights with a raycast

Hey Guys,

I am new here(also new to unity)

Let me first explain what I am working on so you can understand the context of what I am trying to achieve.

What I use: Unity Pro 3.4.2 City Engine Some other external packages.

My game: I am building a whole dynamic city(GTA style). The city will "live" with loads of people who go around their lives(For example: Eat, sleep, word, get fired, etc) This is still being worked on.

For the moment I am working on the GFX of the city itself. I already have the city itself(buildings, streets)a dynamic night/day cycle and a fully dynamic weather system(volumetric clouds) and dynamic shadows of the sun.

At night, I want the city to turn on its (dynamic) streetlights(MAANY LIGHTS), this takes down the performance of the game very very heavily. So what I would like to do is some kind of LOD system where lights turn on when the player gets within the xx radius of a light and turn off when they are outside a certain radius of the player.

Seeing how I want the lights to drop dynamic shadows on objects around the city I do not want it lightmapped.

I hope this will make performance much better.

Can anyone help me achieve this?

PS, Isn't it supposed to be possible to get dynamic shadows with point and spot lights in the latest unity? Somehow they don't. PPS, I am fairly new with unity, so please consider that!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by PuttPutt · Dec 19, 2011 at 10:53 PM

Solved!

By using a custom var to check for the distance between the main camera and the light(s) (linecast) and when the distance is shorter than xx meters, the command:

light.enabled = true;

else

light.enabled = false;

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MarkD · Apr 04, 2014 at 06:18 PM 0
Share

Depending on your rays this could still become very intensive. Try setting up a sphere collider and make it a trigger, then place a script on that collider with a for loop that turns of every script outside of it and enable all the lights inside it.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to obtain third person accuracy 0 Answers

Seperate switches for individual lights 0 Answers

Unity and Raycasting/collision 1 Answer

Top down LOS/Field of View 0 Answers

gameObject not dynamically scaling via the update method 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges