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 WillTAtl · Nov 01, 2011 at 12:56 AM · ioslightingiphonelocalscale

multiplying transform.localScale causing lighting issues

As an initial learning project, making a simple asteroids-type game. Originally I was using unity spheres for the asteroids, and everything worked fine, but when I replaced them with meshes exported from Blender (also spheres - I'm not an artist, just wanted to try importing), I started having issues with lighting. The problem occurs only on my iPhone 3gs and in the iPhone simulator, does not occur in web, windows, or osx builds.

Asteroids are instantiated by a GameManager script attached to the camera; when only one asteroid is created, lighting is fine. If more than one are created, or that one is shot and splits into two, the problem appears, and the objects stop being lit (single directional light in scene) when more than one is on-screen at a time.

This screenshot, I just split one asteroid into two, which are now dark (doesn't appear to be ambient lighting, either...) alt text

A second later, one has gone off the left edge of the screen, and the first lights properly again... alt text

Bizarrely, it seems to be related to the scaling applied to the asteroids - when starting with 2, this behavior occurs. When one is shot and split, it's two smaller children demonstrate the glitch, and the remaining "big boy" lights fine. Split the other big boy, giving 4 1/2-size versions, and all four draw dark unless only one is on screen.

I assume I'm Doing It Wrong™, as I'm new to unity, but searching google and unityAnswers has turned up nothing helpful. I've determined that it is scaling that is the problem - if I comment out the line that applies a change to the scale, so all asteroids are the same size, lighting behaves as expected, regardless of splitting or how many asteroids are visible. The only place I am scaling is in this function from my asteroid script. This is called every time an asteroid is created, and commenting out the last line eliminates the lighting problem - and causes all asteroids to be the same size, obviously not an acceptable solution!

here is the function containing the scaling line...

 function SetupProps(scale:float, points:int, mag:int)
 {
     magnitude = mag;
     pointValue = points;
     transform.localScale = transform.localScale*scale;
 }

I'm aware I could work around this issue by using separate pre-scaled prefabs for each size of asteroid, but I'd really like to know how to make dynamic scaling work properly.

Thanks in advance, any help will be appreciated!

:edit: forgot to mention, the scene consists of just a single directional light.

Comment
Add comment · Show 1
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 idunlop_oefun · Aug 11, 2012 at 07:37 PM 0
Share

Probably related to bug that appears to have been fixed in 3.5.5f2. See this: http://answers.unity3d.com/questions/278313/how-do-i-fix-directional-light-problem-with-multip.html

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by eddieparker · May 20, 2012 at 02:09 AM

I don't know if this is related to you, but I had a similar issue when my z component of my scale was zero. Make sure the components of all your localScale elements are non-zero mayhaps?

Comment
Add comment · Show 2 · 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 ryanroundhouse · Oct 10, 2014 at 01:52 AM 1
Share

this worked for me. I kept the z component from zero'ing and the lighting worked.

avatar image shinichikudo997 · Jul 05, 2020 at 07:38 AM 0
Share

I was plucking my hair off and i never noticed that one of my scale value was zero...so many thanks

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Spotlights on iPhone game suddenly are all dead. Any thoughts? 0 Answers

Lighting in AR for iOS 0 Answers

Lighting on iPhone brighter than Editor/Mac/PC 0 Answers

Lighting works for iPad but not iPhone? 0 Answers

Lighting not working on iOS device with fpc 0 Answers


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